📄 exp7_1.cpp
字号:
/*范例:为实验六题1的Rectangle类增加加减复合赋值和加减运算符重载函数。
加减复合赋值语义定义为固定长方形的左上角,对右下角的坐标进行加减运算,
使新矩形的长宽为原两矩形长宽之和或差,对加和减复合赋值定义为成员函数。
两个矩形加减运算定义为友元函数。
*/
#include <iostream.h>
#include "rect.h"
void main()
{
Rectangle rect;
rect.Show();
rect.Assign(100,200,300,400);
rect.Show();
Rectangle rect1(0,0,200,200);
rect1.Show();
rect += rect1;
rect.Show();
rect -= rect1;
rect.Show();
Rectangle rect2;
rect2 = rect+rect1;
rect2.Show();
rect2 = rect-rect1;
rect2.Show();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -