作业帮 > 综合 > 作业

设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/06/05 20:06:59
设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
class Rectangle
{int left,top;
int right,bottom;
public:
Rectangle(int l=0,int t=0,int r=0,int b=0);
Rectangle(){};
void Assign(int l,int t,int r,int b);
void SetLeft(int t){left=t;}
void SetRight(int t){right=t;}
void SetTop(int t){top=t;}
void SetBottom(int t){bottom=t;}
void show();
void operator+=(Rectangle&);
void operator-=(Rectangle&);
/*void operator*=(Rectangle&);*/
friend Rectangle operator +(Rectangle&,Rectangle&);
friend Rectangle operator-(Rectangle&,Rectangle&);
/*friend Rectangle operator*(Rectangle&,Rectangle&);*/
};
#include
#include "rect.h"
using namespace std;
Rectangle::Rectangle(int l,int t,int r,int b){
left=l;top=t;
right=r;bottom=b;
}
void Rectangle::Assign(int l,int t,int r,int b)
{
void Rectangle::show(){
cout