#include using namespace std; class shape2D { public: void setWidth(int w) { width = w; } void setHeight(int h) { height = h; } shape2D(int wd=1, int ht=1) { width = wd; height = ht; cout << "shape2D constructed.." << endl; } void prtShape() { cout << width << "," << height << endl; } protected: int width; int height; };// class shape2D class Rectangle: public shape2D { public: Rectangle(int wd, int ht) { width=wd; height=ht; cout << "Rectangle constructed, with width,height as " << width << "," << height << endl; } int getArea() { return (width * height); } };// class Rectangle class Triangle: public shape2D { public: Triangle(int wd, int ht) { width=wd; height=ht; cout << "Triangle constructed, with width,height as " << width << "," << height << endl; } int getArea() { return 0.5*(width * height); } };// class Triangle int main() { Rectangle r(3,4); int rA = r.getArea(); cout << "Area: " << rA << endl; Triangle t(3,4); int tA = t.getArea(); cout << "Area: " << tA << endl; return 0; }