作业帮 > 综合 > 作业

设计出矩形类,具有长宽,构造函数,析构函数和其他成员函数,并输出当前长,宽,面积.

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/13 09:37:58
设计出矩形类,具有长宽,构造函数,析构函数和其他成员函数,并输出当前长,宽,面积.
速速回答
#includeclass Rectangle{private:double x1,y1,x2,y2;public:Rectangle(double Dx1,double Dy1,double Dx2,double Dy2); int RT(); double Getarea(); double Getround(); void show();};Rectangle::Rectangle(double Dx1,double Dy1,double Dx2,double Dy2){ x1=Dx1; y1=Dy1; x2=Dx2; y2=Dy2;}int Rectangle::RT(){ if(x1==x2||y1==y2)return 0; return 1;}double Rectangle::Getarea(){ return ((x2-x1)*(y2-y1));}double Rectangle::Getround(){ return (2*((x2-x1)+(y2-y1)));}void Rectangle::show(){ cout