#include<iostream>
using namespace std;
class complex
{
double real;
double imag;
public:
int operator==(complex c)
{
if( (real==c.real) && (imag==c.imag) )
return 1;
else
return 0;
}
void display()
{
cout<<“(“<<real<<“,”<<imag<<“)”<<endl;
}
void set()
{
cout<<“Enter real: “<<endl;
cin>>real;
cout<<“Enter imag: “<<endl;
cin>>imag;
}
};
int main()
{
complex c1,c2;
c1.set();
c2.set();
if(c1==c2)
cout<<“Numbers are equal: “<<endl;
else
cout<<“Numbers are not equal: “<<endl;
c1.display();
c2.display();
system(” pause”);
}
<—end—>
output:
Enter real:
3
Enter imag;
4
Enter real:
3
Enter imag:
4
Numbers are equal:
(3,4)
(3,4)