//program to overload the '==' operator
#include
#include

class eqeq
	{
	int r;
	float i;

	public:
	eqeq()
		{
		r=0;
		i=0;
		}
	eqeq(int x,int y)
		{
		r=x;
		i=y;
		}
	void input()
		{
		cout<<"\nEnter the real part(r):";
		cin>>r;
		cout<<"\nEnter the imaginary part(i):";
		cin>>i;
		}
	void operator==(eqeq q)
		{
		if(i==q.i)
			{
			if(r==q.r)
				{
				cout<<"\nBoth complex numbers are equal";
				}
			}
		else
			cout<<"\nThe two numbers are not equal";
		}
	};

void main()
	{
	eqeq a,b;
	a.input();
	b.input();
	a==b;
	getch();
	}

    Source: geocities.com/cplusplussurvivalkit