Write a program to create a base class named “circle”. Derive
another class “cylinder” from it. The program should calculate
total surface area of circle and cylinder using the concept of
inheritance. Circle should have data fields i.e. radius, area and
method getRadius ( ) should take value of radius from user.
Cylinder should have additional data field i.e. height and
additional method getHeight ( ) to assign value of height.
Similarly, area ( ) function calculates area and display ( )
function prints the final area of the created objects i.e circle
and cylinder. (Circle surface area=pi*r*r and cylinder surface
area=2*pi*r*r+2*r*h)
Write a program to create a base class named “circle”. Derive another class “cylinder” from it. The program should calcu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am