⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shiti4_4_3.cpp

📁 为初学者提供的最佳的C++程序设计源程序库
💻 CPP
字号:
#include<iostream.h>
class Vector
{
public:
	Vector(){}
	Vector(int i,int j){x=i;y=j;}
	friend Vector operator+=(Vector v1,Vector v2)
	{
		v1.x+=v2.x;
		v1.y+=v2.y;
		return v1;
	}
	Vector operator-=(Vector v)
	{
		Vector temp;
		temp.x=x-v.x;
		temp.y=y-v.y;
		return temp;
	}
	void display(){cout<<"("<<x<<","<<y<<")"<<endl;}
private:
	int x,y;
};
void main()
{
	Vector v1(1,2),v2(3,4),v3,v4;
	v3=v1+=v2;
	v4=v1-=v2;
	cout<<"v1=";
	v1.display();
	cout<<"v2=";
	v2.display();
	cout<<"v3=";
	v3.display();
	cout<<"v4=";
	v4.display();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -