// derived classes #include using namespace std; class Polygon { protected: int width, height; public: void set_values (int a, int b) { width=a; height=b;} }; class Rectangle: public Polygon { public: int area () { return (width * height); } }; class Triangle: public Polygon { public: int area () { return (width * height / 2); } }; int main () { Rectangle rect; Triangle trgl; rect.set_values (4,5); trgl.set_values (4,5); cout << "Rectangle area is " << rect.area() << endl; cout << "Triangle area is " << trgl.area() << endl; getchar(); return 0; }