#include<iostream>
using namespace std;
const double pi=3.1415926;
class Circle
{double radius;
double x,y;
public:
Circle(double x1,double y1,double r1){x=x1;y=y1;radius=r1;}
void setx(int nx){x=nx;}
void sety(int ny){y=ny;}
void setr(int nr){radius=nr;}
double getx(){return x;}
double gety(){return y;}
double getradius(){return radius;}
};
int main()
{
Circle a(2.0,5.0,6),b(a);
b.setr(5);
cin>>a;
if(a<=b)
cout<<"a is smaller than or equal to b."<<endl;
else
cout<<"a is larger than b."<<endl;
cout<<b.getarea()<<endl;
cout<<b.getlength()<<endl;
return 0;
}
#include<iostream>
using namespace std;
const double pi = 3.1415926;
class Circle
{
double radius;
double x, y;
public:
Circle(double x1, double y1, double r1){ x = x1; y = y1; radius = r1; }
void setx(int nx){ x = nx; }
void sety(int ny){ y = ny; }
void setr(int nr){ radius = nr; }
double getx(){ return x; }
double gety(){ return y; }
double getradius(){ return radius; }
// 获取周长
double getlength(){ return pi * 2 * radius; }
// 获取面积
double getarea(){ return pi*radius*radius; }
// 友元函数 重载 >> 流运算符
friend istream & operator>>(istream & is, Circle & c)
{
cout << "input radius:";
is >> c.radius;
cout << "input x:";
is >> c.x;
cout << "input y:";
is >> c.y;
return is;
}
// 重载 <= 运算符
bool operator <= (const Circle & c)
{
if (radius <= c.radius){
return true;
}
else{
return false;
}
}
};
int main()
{
Circle a(2.0, 5.0, 6), b(a);
b.setr(5);
cin >> a;
if (a <= b)
cout << "a is smaller than or equal to b." << endl;
else
cout << "a is larger than b." << endl;
cout << b.getarea() << endl;
cout << b.getlength() << endl;
return 0;
}