#ifndef ___SHAPE__HPP__ #define ___SHAPE__HPP__ #include // base class class shape { protected: int x, y; public: shape():x(0), y(0) { }//x = y = 0; void move(int nx, int ny) { x = nx; y = ny; } virtual void draw() { std::cout << "Shape: " << x << ", " << y << std::endl; } }; class rectangle :public shape { protected: int height, width; public: rectangle(int h = 0, int w = 0):shape(), height(h), width(w) {} void draw() { std::cout << "Rectangle: (" << x << ", " << y << ") " << width << " " << height << std::endl; } }; class square :public rectangle { public: square(int w = 0) :rectangle(w, w) {} void draw() { std::cout << "Square: (" << x << ", " << y << ") " << width << " " << height << std::endl; } }; class triangle :public shape { protected: int base, altitude; public: triangle(int b, int a) :shape(), base(b), altitude(a) {} void draw() { std::cout << "Triangle: (" << x << ", " << y << ") " << base << " " << altitude << std::endl; } }; class circle:public shape { protected: int radius; public: circle(int r = 0) :shape(), radius(r) {} void draw() { std::cout << "Circle: (" << x << ", " << y << ") " << radius << std::endl; } }; #endif