class rectangular { public: int width; int height; int area() { return width*height; } }; int main() { rectangular x; x.width=5; x.height=6; printf("%d",x.area()); }
class rectangular { public: int width; int height; int area() { return width*height; } }; class block: public rectangular { public: int depth; int volume() { return width*height*depth; } }; int main(int argc, char **argv) { block x; x.width=5; x.height=6; x.depth=2; printf("%d",x.volume()); return 0; }