//Program to overload uary operator(++).

| |


#include<iostream.h>
#include<conio.h>
class complex
{ private:
float x;
float y;
public:
complex(){}
complex(float real,float imag)
{ x=real;y=imag;}
complex operator+(complex);
void display(void);
};
complex complex::operator+(complex c)
{ complex temp;
temp.x=x+c.x;
temp.y=y+c.y;
return(temp);
}
void complex::display(void)
{ cout<<x<<"+i"<<y<<"\n";
}
int main()
{ clrscr();
complex c1,c2,c3;
c1=complex(2.5,3.5);
c2=complex(1.6,2.7);
c3=c1+c2;
cout<<"First complex no.=";c1.display();
cout<<"second complex no.=";c2.display();
cout<<"\nSum of two complex numbers=";c3.display();
getch();
return 0;
}
<