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

问题描述:

设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
1个回答 分类:综合 2014-10-21

问题解答:

我来补答
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
 
 
展开全文阅读
剩余:2000