Base Class
| 14 | |
| 15 | // Base Class |
| 16 | class Shape |
| 17 | { // Abstract class |
| 18 | protected: |
| 19 | double base; |
| 20 | double height; |
| 21 | |
| 22 | public: |
| 23 | void get_data(double base, double height) |
| 24 | { |
| 25 | this->base = base; |
| 26 | this->height = height; |
| 27 | } |
| 28 | void virtual display_area() = 0; // pure virtual function |
| 29 | }; |
| 30 | |
| 31 | // Triangle class to calculate the area of triangle |
| 32 | class Triangle : public Shape |