#include using namespace std; class shape { protected: int x_; int y_; public: shape(int newx, int newy); int getx(); int gety(); void setx(int newx); void sety(int newy); void moveto(int newx, int newy); void print(); }; using namespace std; shape::shape(int newx, int newy) { moveto(newx, newy); } int shape::getx() { return x_; } int shape::gety() { return y_; } void shape::setx(int newx) { x_ = newx; } void shape::sety(int newy) { y_ = newy; } void shape::moveto(int newx, int newy) { setx(newx); sety(newy); } void shape::print() { cout << " Shape " << endl; cout << " x = " << x_ << endl; cout << " y = " << y_ << endl; } class circle : public shape { private: int radius_; public: circle(int newx, int newy, int newradius); int getradius(); void setradius(int newradius); void draw(); void print(); }; circle::circle(int newx, int newy, int newradius) : shape(newx, newy) { setradius(newradius); } int circle::getradius() { return radius_; } void circle::setradius(int newradius) { radius_ = newradius; } void circle::print() { cout << " Circle " << endl; cout << " x = " << x_ << endl; cout << " y = " << y_ << endl; cout << " radius = " << radius_ << endl; } class rectangle : public shape { private: int width_; int height_; public: rectangle(int newx, int newy, int newwidth, int newheight); int getwidth(); int getheight(); void setwidth(int newwidth); void setheight(int newheight); void print(); }; rectangle::rectangle(int newx, int newy, int newwidth, int newheight) : shape(newx, newy) { setwidth(newwidth); setheight(newheight); } int rectangle::getwidth() { return width_; } int rectangle::getheight() { return height_; } void rectangle::setwidth(int newwidth) { width_ = newwidth; } void rectangle::setheight(int newheight) { height_ = newheight; } void rectangle::print() { cout << " Rectangle " << endl; cout << " x = " << x_ << endl; cout << " y = " << y_ << endl; cout << " width = " << width_ << endl; cout << " height = " << height_ << endl; } void foo() { shape s1(10, 10); s1.print(); cout << s1.getx() << endl; cout << s1.gety() << endl; s1.moveto(20, 20); s1.print(); circle c1(10, 10, 100); c1.print(); cout << c1.getx() << endl; cout << c1.gety() << endl; cout << c1.getradius() << endl; c1.moveto(20, 20); c1.print(); rectangle r1(10, 10, 100, 200); r1.print(); cout << r1.getx() << endl; cout << r1.gety() << endl; r1.moveto(20, 20); r1.print(); } int main() { cout << " Program starts" << endl; foo(); cout << " Program ends " << endl; return(0); }