Firstly, neither cout nor aGenericPlayer can overload anything. These are objects, and overloading is type-based (even if you donโt usually say that type X overloads << , but rather that there is overload << , which can take type X as the second argument).
Secondly, overload resolution is based on all arguments, not just one. There are about twenty different << overloads for std::istream (which is the base class of type std::cout ), but none (at least in the standard library) take GenericPlayer as the second parameter. Therefore, they cannot be used if the second operand is not a GenericPlayer . Similarly, you can have operator<<( int, GenericPlayer const& ) , in addition to what you have; it will be called if the left side was of type int , and the right side of type GenericPlayer . (I can not think of a single case where this will not be an operator overload, but the language of course allows this.)
source share