Question: Inheritance / Virtual functions Write a C + + program that performs the following tasks: class Shape Create a base class Shape with the following
InheritanceVirtual 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 MPI for constant value value of
Output Example
Enter length and width of the rectangle:
Enter radius of the circle:
Rectangle Area:
Circle Area:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
