Page 1 of 1

Protected Data Members of class Shape such as: c_radius, s_area, s_length, s_width, t_base, t_height (int) c_area, t_are

Posted: Fri Apr 29, 2022 7:08 am
by answerhappygod
Protected Data Members of class Shape such as:
c_radius, s_area, s_length, s_width, t_base, t_height (int)
c_area, t_area (float) pie = 3.1416 (const int)
Public Member Functions of class Shape such as:
void calculateArea() – It will print “Parent Class is generic,
your roll number and name”.
Inherited Data Members of class Circle such as: It will inherit
c_radius and c_area from shape class.
Public Member Functions of class Circle such as: void
calculateArea () –
It will take input c_radius and calculate area, store in c_area
and display area of the circle.
Inherited Data Members of class Square such as: It will inherit
s_length, s_width and s_area from shape class.
Public Member Functions of class Square such as:
void calculateArea () – It will take input s_length and s_width
and calculate area, store in s_area and display area of the
square.
Inherited Data Members of class Triangle such as: It will
inherit t_base, t_height and t_area from shape class.
Public Member Functions of class Triangle such as:
void calculateArea () – It will take input t_base and t_height
and calculate area, store in t_area and display area of the
triangle.
Create a UML diagram. Do the following operations in main
function:
1. Create a pointer object of class Shape and store the address
of the Circle class and call member function calculateArea().
2. Use a pointer object of class Shape and store the address of
the Square class and call member function calculateArea().
3. Use a pointer object of class Shape and store the address of
the Triangle class and call member function calculateArea().