Question: Define an abstract base class called GeometricObject. The GeometricObject class should have the following members: Private Member Variable: area: a double used to hold the

Define an abstract base class called GeometricObject. The GeometricObject class should have the following members: Private Member Variable: area: a double used to hold the shape's area. Public Member Functions: getArea: This function should return the value in the member variable area. calcArea: This function should be a pure virtual function. Next, define a class named Square. It should be derived from the GeometricObject class. It should have the following members: Private Member Variables: side: a double Public Member Functions: constructor: It accepts a value for the side. calcArea: This function calculates the area of the circle (area = side * side) and stores the result in the inherited member area. Next, define a class named Triangle. It should be derived from the GeometricObject class. It should have the following members: Private Member Variables: base: a long integer height: a long integer Public Member Functions: constructor: It accepts values for the base and the height. calcArea: This function calculates the area of the rectangle (area = 1/2 base * height) and stores the result in the inherited member area. After you have created these classes, create a driver program that defines a Square object and a Triangle object. Demonstrate that each object properly calculates and reports its area. c++ code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!