E
Eric Lilja
From a book, I know the following is true for the comparison operators:
An overloaded operator that is a class member is only considered
when the operator is used with a *left* operand that is an object
of that class.
And is that also the reason why if you use class member functions for
operators << and >> you have to write:
someclass << cout;
someclass >> cin;
?
Thus you usually make them friends so you avoid have to use cin and
cout
in such a weird manner.
/ E
An overloaded operator that is a class member is only considered
when the operator is used with a *left* operand that is an object
of that class.
And is that also the reason why if you use class member functions for
operators << and >> you have to write:
someclass << cout;
someclass >> cin;
?
Thus you usually make them friends so you avoid have to use cin and
cout
in such a weird manner.
/ E