Create a class called Sphere with private data member radius. Include the following public functions/methods:
Default constructor that sets the radius to 1
Parameterized constructor that lets the client set the radius
getRadius – return the radius
setRadius – allow the client to specify the radius
calcVolume – calculate the volume of the sphere
display – display the radius and volume
Next, create a Ball class that is derived publicly from Sphere. The Ball class adds a private data member, representing the name of the ball, e.g., soccer ball. In addition, provide the following public functions:
Default constructor – initialize the Sphere class and call the function setName with the null string
Parameterized Constructor – the user passes in the radius and the name of the ball
getName – sends back the ball’s name
setName – allows the client to set the name
reset – allows the client to specify a new radius and name
display – displays the name and then calls the sphere class display function
Also, create a Balloon class that is derived from Ball. The Balloon class adds a private data member, representing the name of the balloon, e.g., hydrogen balloon. In addition, provide the following public functions/methods:
Default constructor – initialize the Sphere class and call the function setName with the null string
Parameterized Constructor – the user passes in the radius and the name of the balloon
getName – sends back the balloon’s name
setName – allows the client to set the name
reset – allows the client to specify a new radius and name
display – displays the name and then calls the sphere class display function
Create a class that will handle polymorphism through the base class Sphere and include all of these classes in a program. Write a separate program with a main that the functions of inheritance and polymorphism.
IMPORTANT: Pack all of your classes in a Namespace header file named, “SphereNameSpace.h”