The correct way to have operator<< and operator>> work for reading and
writing a class is to declare them as functions in the namespace
containing the object. Declaring them as member functions does something
else entirely (or absolutely nothing useful, depending on how you do
it). The problem is that the compiler searches for operators by checking
member functions of the left hand object (for i/o it is the stream
itself), then the current namespace and the namespaces containing the
arguments. It never looks for member functions of the right hand type.