// abstract base class // In an abstract base classes we could leave that area() member function // without implementation at all. This is done by appending = 0 (equal to zero) // to the function declaration. #include using namespace std; class Polygon { protected: int width, height; public: void set_values (int a, int b) { width=a; height=b; } virtual int area (void) = 0; }; class Rectangle: public Polygon { public: int area (void) { return (width * height); } }; class Triangle: public Polygon { public: int area (void) { return (width * height / 2); } }; int main () { Rectangle rect; Triangle trgl; Polygon *poly1 = ▭ Polygon *poly2 = &trgl; poly1->set_values (4,5); poly2->set_values (4,5); cout << "The area of rectangle is " << poly1->area() << endl; cout << "The area of triangle is " << poly2->area() << endl; getchar(); return 0; }