C++ Programming Problems: Kkwp1 Kkwp2 KKWWP
C++ Programming Problems: Kkwp1 Kkwp2 KKWWP
1.
Shape
Circle Rectangle
Observe the figure above. This inheritance hierarchy contains six different
classes with defined functions. Assume appropriate functions to input the
values. Apply run-time polymorphism to call area( ) and volume( ) function
from different classes to calculate area and volume of particular shape.
Prototype of area( ) and volume( ) must be same wherever it is defined.
Formulae:
Area: Circle: ∏ * radius2 Rectangle: length * width
3
Volume: Sphere: (4/3) * ∏ * r , Cone: (1/3) * ∏ * radius2 * height,
Cube: side3
2.
Above three classes are defined with given variables and functions. Define
appropriate constructors to initialize the values. Create an independent function
which has objects of all three classes as arguments. This function will call the
-1-
print( ) function of particular object which has highest value of intake. The
print( ) function prints name and intake.
3.
Computer
private:
int array[10]
-2-