#include <iostream>
using namespace std;
class Rect
{
private:
double len,width;
public:
Rect(double a=0,double b=0);
Rect(const Rect &r);
void show(const char *name);
};
Rect::Rect(double a,double b)
{
len =a;
width=b;
}
Rect::Rect(const Rect &r)
{
len=r.len;
width=r.width;
}
void Rect::show(const char *name)
{
cout<<"the length and width of "<<name<<" is:"<<len<<","<<width<<endl;
cout<<"the perimeter of "<<name<<" is:"<<(len+width)*2.0<<endl;
cout<<"the area of "<<name<<" is:"<<len*width<<endl;
}
int main()
{
double x,y;
cin>>x>>y;
if(x<0||y<0)
{
x=0;
y=0;
}
Rect r1(x,y);
r1.show("r1");
Rect r2=r1;
r2.show("r2");
}
标签:const,oj,show,double,len,width,sdut,Rect,周长 From: https://blog.51cto.com/u_12528551/5900088