Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pure Abstract Base Class Project Define a pure abstract base class called Basicshape. The BasicShape class should have the following members. Protected Member Variable area,

image text in transcribed
Pure Abstract Base Class Project Define a pure abstract base class called Basicshape. The BasicShape class should have the following members. Protected 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 a class named circle. It should be derived from the BasicShape class. It should have the following members: Protected Member Variables centerY, a long integer used to hold the y 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, centerY, and radius. Should call the overridden caleArea function described below. getCenterX. Returns the value in centerX.getCenterY. Returns the value in centerY. calcArea. Calculates the area of the circle using the formula area = 3.14159 * radius * 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. Protected 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. Returns the value in width. getLength. Returns the value in length. calcArea. Calculates the area of the rectangle using the formula are = length * width and stores the result in the inherited member area. After you have created these classes, create a driver program that declares a Circle object and a Rectangle object. Demonstrate that each object properly calculates and reports its 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_2

Step: 3

blur-text-image_3

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions