#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 << "," << y << ")";}
private:
int x;
int y;
};
const double pi = 3.14;
class Circle:public Point
{
public:
Circle(int a,int b,int c):Point(a,b){change(c);}
void change(int a){r = a;}
double area(){return pi * r * r;}
void disp()
{
cout << "圆心坐标: ";
Point::disp();
cout << "\n圆半径为: " << r << "\n圆面积为: " << area() << endl;
}
private:
int r;
};
int main()
{
Circle c(2,3,4);
c.disp();
cout << endl;
c.change(10); // 改变圆的半径
c.set(6,7); // 改变圆心坐标
c.disp();
return 0;
}
class Point {
int x;
int y;
public:
Point(int _x, int _y) : x(_x), y(_y) {}
int x() {return x;}
int y() {return y;}
void x(int _x) {x = _x;}
void y(int _y) {y = _y;}
};
class Circle : public Point {
int r;
public:
Circle(_x, _y, _r) : Point(_x, _y), r(_r) {}
int r() {return r;}
void r(int _r) {r = _r;}
float area() {return 3.1415 * r * r;}
};
#ifndef POINT_H
#define POINT_H
#include
using namespace std;
class Point{
int x,y;
public:
Point(int a,int b):x(a),y(b){};
void setx(int a){x=a;}
void sety(int b){y=b;}
int getx(){return x;}
int gety(){return y;}
void Print(){ cout<<'<'<
class Circle:public Point{
double radius;
public:
Circle(int a,int b,double r):Point(a,b),radius(r){};
void setradius(double r){radius=(r>=0?r:0);}
double getradius(){return radius;}
double area(){return 3.14156*radius*radius;}
virtual void Print(){
Point::Print();
cout<
};
#endif
#include
using namespace std;
#include"Point.h"
int main()
{
Circle circle(1,2,5);
circle.area();
circle.Print();
return 0;
}
class Point
{
public:
int x;
int y;
public:
Point( int X = 0, int Y = 0 )
{
x = X;
y = Y;
}
};
class Circle : public Point
{
public:
int r;
public:
Circle( int X = 0, int Y = 0, int R = 0 )
{
x = X;
y = Y;
r = R;
}
}