#ifndef __SHAPE_HPP__ #define __SHAPE_HPP__ #include // parent class class shape { protected: int x, y; public: shape() { x = y = 0; } shape(int nx, int ny) { x = nx; y = ny; } void move(int nx, int ny) { x = nx; y = ny; } virtual void draw() = 0; // abstract virtual function }; class rectangle : public shape { protected: double length, width; public: rectangle(double l, double w) : shape() { length = l; width = w; } virtual void draw() { std::cout << "Rectangle: " << "x = " << x << " y = " << y << " length = " << length << " width = " << width << std::endl; } }; class square : public rectangle { public: square(double s) : rectangle(s, s) { } virtual void draw() { std::cout << "Square: " << "x = " << x << " y = " << y << " side length = " << length << std::endl; } }; class triangle : public shape { protected: double base, altitude; public: triangle(double b, double a) : shape() { base = b; altitude = a; } virtual void draw() { std::cout << "Triangle: " << "x = " << x << " y = " << y << " base = " << base << " altitude = " << altitude << std::endl; } }; class circle : public shape { protected: double radius; public: circle(double r) : shape() { radius = r; } virtual void draw() { std::cout << "Circle: " << "x = " << x << " y = " << y << " radius = " << radius << std::endl; } }; #endif