Define a pure abstract base class called BasicShape . The BasicShape class should have the following members:   Private Member Variable: area, type double used to hold the shape's area. Public Member Functions: setArea: assigns received argument to area variable. 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, type integer used to hold the x coordinate of the circle’s center. centerY, type integer used to hold the y coordinate of the circle’s center. radius, type double used to hold the circle's radius. Public Member Functions: constructor—accepts values for centerX, centerY, and radius. Should also call the overridden calcArea function described below. getCenterX—returns the value in centerX. getCenterY—returns the value in centerY. calcArea—calculates the area of the circle (area = 3.14159 * radius * radius) and stores the result in the inherited member variable area in base class.   Next, define a class named Rectangle. It should be derived from the BasicShape class. It should have the following members: Private Member Variables: width, type double used to hold the width of the rectangle. length, type double used to hold the length of the rectangle. Public Member Functions: constructor—accepts values for width and length. Should also 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 (area = length * width) and stores the result in the inherited member variable area in base class.   Write a main function that will declare pointer array of type BasicShape having size 4 and initialize the array with the objects of type circle, circle, rectangle and rectangle respectively. Then using for loop, display the area of those shapes (circle and rectangle) whose area > 100 .   Note: Do not change the names of functions and variables. Otherwise, marks will be deducted. Do not define extra functions

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.4: Class Inheritance And Polymorphism
Problem 5E
icon
Related questions
Question

plz do it urgent in devc++. and plzz dont reject it

 

Define a pure abstract base class called BasicShape . The BasicShape class should have the following members:

 

Private Member Variable:

area, type double used to hold the shape's area.

Public Member Functions:

setArea: assigns received argument to area variable.

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, type integer used to hold the x coordinate of the circle’s center.

centerY, type integer used to hold the y coordinate of the circle’s center.

radius, type double used to hold the circle's radius.

Public Member Functions:

constructor—accepts values for centerX, centerY, and radius. Should also call the overridden calcArea function described below.

getCenterX—returns the value in centerX.

getCenterY—returns the value in centerY.

calcArea—calculates the area of the circle (area = 3.14159 * radius * radius) and stores the result in the inherited member variable area in base class.

 

Next, define a class named Rectangle. It should be derived from the BasicShape class. It should have the following members:

Private Member Variables:

width, type double used to hold the width of the rectangle.

length, type double used to hold the length of the rectangle.

Public Member Functions:

constructor—accepts values for width and length. Should also 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 (area = length * width) and stores the result in the inherited member variable area in base class.

 

Write a main function that will declare pointer array of type BasicShape having size 4 and initialize the array with the objects of type circle, circle, rectangle and rectangle respectively. Then using for loop, display the area of those shapes (circle and rectangle) whose area > 100 .

 

Note: Do not change the names of functions and variables. Otherwise, marks will be deducted. Do not define extra functions

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,