📄
字号:
#include<iostream.h>
class vector
{
int x,y;
public:
vector(){};
vector(int x1,int y1){x=x1;y=y1;}
friend vector operator +=(vector v1,vector v2)
{
v1.x+=v2.x;
v1.y+=v2.y;
return v1;
}
vector operator-=(vector v)
{
vector tmp;
tmp.x=x-v.x;
tmp.y=y-v.y;
return tmp;
}
void display()
{
cout<<"("<<x<<","<<y<<")"<<endl;
}
};
void main()
{
vector v1(6,8),v2(3,4),v3,v4;
cout<<"v1=";
v1.display();
cout<<"v2=";
v2.display();
v3=v1+=v2;
cout<<"v3=";
v3.display();
v4=v1-=v2;
cout<<"v4=";
v4.display();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -