answersLogoWhite

0


Best Answer

This is not a question, it is an assignment.

class Geo {

public:

virtual double area (void) const = 0;

virtual ~Geo (void) {}

// ...

};

class Rect : public Geo {

private:

double m_width;

double m_height;

public:

Rect (double width, double height): m_width (width), m_height (height) {}

double area (void) const override { return m_width * m_height; }

~Rect (void) override {};

// ...

};

class Sqr : public Rect {

public:

Sqr (double width): Rect {width, width} {}

~Sqr (void) override {}

// ...

};

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Implement a base class Geo and derived from this class Rect a constraint such as any derived classes from Geo must have method to calculate the area.Derive from Rect class Sqr its const take one value?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you calculate the mode of grouped data if there are two classes with the same highest frequency?

Both classes are modal classes.


How do you calculate GPA with AP and Honors classes?

For regular classes grades have points A=4 B=3 C=2 D=1 For Honors classes you add half a point and for AP classes you add a full point Then you calculate GPA in normal way.


What are the merits and demerits of defining and declaring a pure virtual function in a program?

Merits of defining a pure virtual function: It enforces derived classes to implement the function, ensuring polymorphic behavior. It enables abstract classes to define a common interface. Demerits: It can hinder flexibility as derived classes must implement the function. It may also increase code complexity.


Why an interface can not have anything but constants and abstract methods?

The idea is that an interface is not a class, it is just a specification of what classes that implement it must contain.


Where can I sign up for some ACT prep classes?

There are some online organizations such as Test Prep Review which offer some ACT prep classes. There is a variety of classes to choose from and it is all free of cost! The tutorials are easy to comprehend and implement.


How do you calculate mode with two modal classes?

It is simply a distribution which has two modal classes: you cannot convert two of them into a mode.


How do you implement inheritance in c plus plus?

You implement inheritance by deriving a new class of object from an existing class of object. The existing class is known as the base class of the derived class.Classes declared final cannot be used as bases classes and classes without a virtual destructor (or a virtual destructor override) cannot be used as polymorphic base classes.


What are adapter classes in java?

An adapter class is a class that provides a dummy (empty) implementation for an interface. That way someone who wants to implement the interface but does not want or does not know how to implement all methods, can use the adapter class instead, and only override the methods he is interested in.


Is it possible to implement overriding in every inheritance?

Yes. It is possible to implement overriding in every inheritance level. If there are methods of the same name in multiple classes in the hierarchy the one that is closest to the current object gets invoked. The other methods can be specifically invoked using the super keyword.


What is difference in use between interfaces and abstract classes in java?

While neither abstract classes nor interfaces can be instantiated in Java, you can implement methods in abstract classes. Interfaces can only define methods; no code beyond a method header is allowed.


In the field of computers what does the term java interface mean?

In Java, an interface is a suite of methods that multiple different classes are able to implement. Interfaces are not assigned to any particular class. For example, multiple graphics classes can use the same interface to change their size and colour.


What is a Disconnected data model?

The disconnectedenvironment allows dataretrieved from the datasource to be manipulated and later reconciled with the datasource. The disconnectedclasses provide a common way to work with disconnecteddataregardless of the underlying datasource. They include the DataSet, DataTable, DataColumn, DataRow, Constraint, DataRelationship, and DataView classes.