Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 3 Define a pure abstract base class called BasicShape. The BasicShape class should have the following members Private Member Variable: area a double used

image text in transcribed
Part 3 Define a pure abstract base class called BasicShape. The BasicShape 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 circle. It should be derived from the BasicShape class. It should have the following members: Private Member Variables: -centerX A long integer used to hold the x coordinate of the circle's center -centery A long integer used to hold the y coordinate of the circle's center -radius A double used to hold the circle's radius. Public Member Functions: constructor Accepts values for centerX, center and radius. Should call the overridden calcArea function described below. -getCenter return the value of centerX -getCenter return the value of centery -calcArea calculates the area of the circle (area 3.14159radius radius) and stores the result in the inherited member area. Next, define a class named Rectangle. It should be derived from the BasicShape class. It should have the following members: Private Member Variables: - width, a long integer used to hold the width of the rectangle -length, a long integer used to hold the length of the rectangle. Public Member Functions: - constructor accepts values for width and length Should call the overridden calcArea function described below. - getWidth retums the value in width -getlengh returns the value in length -calcArea calculates the area of the rectangle (area = length width) and stores the result in the inherited member area. After you have created these classes, create a driver program that defines a Circle object and a Rectangle object. Demonstrate in this driver program that each object properly calculates and reports its area Hint: You will need a set Area function in the BasicShape class to store the calculated area

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

Which approach is least fitting for the job? Explain.

Answered: 1 week ago

Question

How is the compensation for sales representatives determined?

Answered: 1 week ago