Q:

operator == () loops for ever

see this very simple code:
struct A
 {   
     bool operator ==(const int &t)
     {
         return *this == t;
     }
 };
void main()
{
    A p;
    p == 2;// this code loops for ever!!! 
}

dose any one know why the code loops for ever ?!
actually the operator ==() calls itself recursively!
Many thanks

A:

Ask yourself this.
What is *this? It's struct A.
So what is *this == t ? It is basically A::operator==() with argument t.
You are calling the same function.

