Write a program to overload increment equal to operator for complex numbers by using class.

#include<iostream>
using namespace std;
class complex
{
double real;
double imag;
public:
complex operator+=(int n)
{
real+=n;
imag+=n;
complex temp;
temp.real=real;
temp.imag=imag;
return temp;
}
void display()
{
cout<<“(“<<real<<“,”<<imag<<“)”<<endl;
}
void set()
{
cout<<“Enter real: “<<endl;
cin>>real;
cout<<“Enter imag: “<<endl;
cin>>imag;
}
};
int main()
{
complex c1;
c1.set();
cout<<“The complex no is: “<<endl;
c1.display();
cout<<“After the incriment of 10: “<<endl;
c1+=10;
c1.display();
system(” pause”);
}

<—-End—->

Output will be:

Enter real:

23

Enter imag:

12

The complex no is:

(23 , 12)

After the incriment of 10:

(33 , 22)