Question: Inheritance / Virtual functions Write a C + + program that performs the following tasks: class Shape Create a base class Shape with the following

Inheritance/Virtual functions
Write a C++ program that performs the following tasks:
class Shape
Create a base class Shape with the following features:
area(): A pure virtual method area() to calculate the area of the shape.
class Rectangle
Rectangle class is a public derived class of Shape class.
Attributes:
length (double)
width (double)
Method:
setlength
setwidth
setLength
setwidth
getLength
getwidth
area (override function)
class Circle
Circle class is a public derived class of Shape class.
Attributes:
radius (double)
Method:
setRadius
getRadius
area (override function)
getRadius
(override function)
Note: Use M_PI for constant value (value of )
Output Example
Enter length and width of the rectangle: 4536
Enter radius of the circle: 8.3
Rectangle Area: 1620
Circle Area: 216.424
Inheritance / Virtual functions Write a C + +

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 Programming Questions!