友元函数重载+运算符

#include
//#include
using namespace std;
class Vector
{
	private:
		int a;
		int b;
	public:
		Vector(){}//定义无参构造函数并赋初值为0; 
		Vector(int i,int j)//重载构造函数; 
		{
			a=i;
			b=j;
		}
		friend Vector operator+(Vector t1,Vector t2);//友元函数重载+运算符; 
		/*{
			Vector tempvector;
			tempvector.a=t1.a+t2.a;
			tempvector.b=t1.b+t2.b;
			return tempvector;
		}*/
		void display()
		{
			cout<<"("<友元函数重载+运算符_第1张图片

你可能感兴趣的:(c++)