Create a base class called ‘shape'. Use this class to store two, ‘double'. type values that could be used to compute the area of figures. Derive two specific classes called ‘triangle' and ‘rectangle' from the base ‘shape’. Add to the base class, a member function 'getdata( )'; to, initialize base class data members and another member function 'display-area ( )' to compute and 'display the area of figures. Make 'display-
area ( )' as s virtual function and redefine this function in the derived classes to suit their requirements.
|Subject||Object Oriented Programming|
|NU Year||Set: 5.(d) Marks: 7 Year: 2010|