Question: Inheritance and Polymorphism Assignment Referring to the packet immediately above( Inheritance and Polymorphism), Expand the program given on pg. 714 in the class to include
Inheritance and Polymorphism Assignment

Referring to the packet immediately above( Inheritance and Polymorphism), Expand the program given on pg. 714 in the class to include a child class called sphere for which the original parent calcvaluI() function will be used to determine the surface area of a sphere and the volume of a sphere. give the child class sphere public access to the parent class circle.
Include a constructor function for sphere:
Sphere(double r =1.0): Circle (r){}
or written as:
Sphere( double r=1.0)
{Circle(r);
}
You will need a calculate surface area function,ex: calcSA(), to calculate the surface area of a sphere with a specified radius and a calculate volume function, ex: calcVol() to calculate the volume of the sphere with a certain radius. Use the circle constructor function Circle(r) to set the value of the radius. Use the calcval() function as part of the formula for calculating surface area and volume. Return the values of the surface area and the volume from the functions in which they were determined to the main function in a cout statement.
The return types for those functions - calcSA() and calcVol() - should be double.
In the main program, instantiate(create) an object of data type sphere, assign a radius at time of creation (constructor for circle will be used implicitly), then afterwards, use the object to call the functions for calculating the surface area and volume. Be sure to make the function calls in the main in a cout statement so the returned values have somewhere to go ( to the screen).
Program 12.8 include #include using namespace std;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
