Saturday, September 29, 2007

a problem in C++ operator overloading

suppose there is a class
class xyz
{
private:
int x;
}

in the program suppose we create an object,

class obj;

in our program we can't access the private data member x,
as obj.x.
but when we overload any operator for the class we can use
obj.x to access the private data member x in the function,
used for overloading the operator.
i can't understand how is this possible.
perhaps this is possible as:
the overloading function is a member function,
or a friend function.