class Point
{
private:
int x;
int y;
public:
Point(int x,int y);
void SetP(int x,int y);
int getX();
int getY();
};
Point::Point(int x,int y)
{
x = x;
y = y;
}
void Point::SetP(int x,int y)
{
x = x;
y = y;
}
int Point::getX()
{
return x;
}
int Point::getY()
{
return y;
}
class Circle
{
private:
int radius;
Point pt;
public:
Circle(Point pt,int r);
float getArea();
void show();
void SetCC(Point pt,int r);
};
Circle::Circle(Point pt,int r)
{
pt.x = pt.x;
pt.y = pt.y;
radius = r;
}
float Circle::getArea()
{
return PI * radius * radius;
}
void Circle::SetCC(Point pt,int r)
{
pt.x = pt.x;
pt.y = pt.y;
radius = r;
}
这个题目其实很明确的告诉你了
1、新建一个circle类
2、创建一个默认构造函数circle()和一个带参数的构造函数circle(int,int)
3、创建4个public函数SetP(int ,int),SetCC(int,int),show()和getArea()
4、自定义若干私有变量