#include <iostream>
using namespace std;
class Complex
{
private:
	double real;                                
	double imag;                               
public:
	Complex();                                
	Complex(double r,double i);				 
	friend Complex operator + (Complex &t1,Complex &t2);//将重载函数作为友元函数 		  
	void display();
};
int main()
{
	Complex t1(1,2);                         
	Complex t2(3,4);					    
	Complex t3;                              
	t3=t1+t2;                                
	cout<<"t1="<<ends;
	t1.display();                               
	cout<<"t2="<<ends;
	t2.display();
	cout<<"t1+t2="<<ends;
		t3.display();
	return 0;
}
Complex::Complex()                      
{
	real=0;
	imag=0;
}
Complex::Complex(double r,double i)           
{
	real=r;
	imag=i;
}
            
Complex operator + (Complex &t1,Complex &t2)     //定义重载函数作为友元函数
{
	Complex t;                                 
	t.real=t1.real+t2.real;                  
	t.imag=t1.imag+t2.imag;  
	return t;   
}
void Complex::display() 
{
	cout<<"("<<real<<","<<imag<<"i)"<<endl;    
}

