Program to overload the operator "=+" and add the complex numbers

   #include 
   #include 

   class complex
	{
	private:
	 float real;
	 float imag;
	public:
	complex()
		{
		real = imag = 0.0;
		}

	void getdata()              // read complex number
		{
		cout << "Real Part : ";
		cin >> real;
		cout << "Imaginary Part : ";
		cin >> imag;
		}

	void outdata( char *msg )        // display complex number
		{
		cout << endl << msg;
		cout << " ( " << real << " , " << imag << "i)\n" ;
		}
	complex operator +=( complex c2 );
	};

   complex complex :: operator += ( complex c2 )
	{
	real = real + c2.real;
	imag = imag + c2.imag;
	return ( *this );
	}

   int main()
	{
	clrscr();
	complex c1 , c2 , c3;
	cout << "Enter Complex Number c1 .. " << endl;
	c1.getdata();
	cout << "Enter Complex Number c2 .. " << endl;
	c2.getdata();
	// Performs 1. c1 += c2 and 2. c3 = c1

	c3 = c1 += c2; // c1 += c2 is evaluated first, and assigned to c3

	cout << "\nOn execution of the Objects..." << endl;\

	c3.outdata("After Addition : ");

	getch();
	return 0;
	}







    Source: geocities.com/cplusplussurvivalkit