设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/30 18:32:33
![设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加](/uploads/image/z/7644107-11-7.jpg?t=%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E7%9F%A9%E5%BD%A2%E7%B1%BB+%E5%8C%85%E6%8B%AC%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0+%E6%9E%90%E6%9E%84%E5%87%BD%E6%95%B0+GET+SET%E5%87%BD%E6%95%B0+%E9%87%8D%E8%BD%BD%E8%BF%90%E7%AE%97%E7%AC%A6+%2B+%E5%B0%86%E4%B8%A4%E4%B8%AA%E7%9F%A9%E5%BD%A2%E7%9B%B8%E5%8A%A0)
设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
设计一个矩形类 包括构造函数 析构函数 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