Query regarding Overloading Address-of Operator
Hi Folks,
Why doesn't overloading the Address-Of Operator result in a recursion???
Code:
class X {
public:
X* operator&() // Compiler internally should convert it as X* operator&(X* const this)
{
cout << " Why does it not result in a recursive call??? " << endl;
return this;
}
};
int main()
{
X ob;
X *prt = &ob;
// implies ==> X* ptr = ob.X::operator&()
// which implies ==> X* prt = X::operator&(&ob);
// My question is since the call to operator& member function must pass the
// address of the calling object, logically shouldn't this result in a recursive call.
// I would like to understand how does it work ??? or rather why it works
}
regards,
Shiv