#include
using namespace std;
class point
{
public:
point(int ix,int iy){set(ix,iy);}
void set(int ix,int iy){x = ix;y = iy;}
void disp(){cout << "x: " << x << "\ty: " << y <<" ";}
private:
int x;
int y;
};
class circle:public point
{
public:
circle(int ix,int iy,int r):point(ix,iy),R(r){}
void disp()
{
cout << "圆心坐标为: ";
point::disp();
cout << "圆半径为: " << R << endl;
}
private:
int R;
};
int main()
{
circle c(3,5,10);
c.disp();
return 0;
}
我觉得圆类应该作为一个基类好点,其成员可以已是Point类的对象,2点确定一个圆嘛