title: C++ << operator overloading
body: <p>As per Deitel's 9ed C++ How to program, p. 444:</p>
  
  <blockquote>
    <p>Why Overloaded Stream Insertion and Stream Extraction Operators Are Overloaded
    as Non-Member Functions</p>
    
    <p>The overloaded stream insertion operator (&lt;&lt;) is used in an expression in which the left operand has type ostream &amp;, as in cout &lt;&lt; classObject. To use the operator in this manner where the right operand is an object of a user-defined class, it must be overloaded as a nonmember function. To be a member function, operator &lt;&lt; would have to be a member of class ostream. This is not possible for user-defined classes, since we are not allowed to modify C++ Standard Library classes.</p>
  </blockquote>
  
  <p>The thing is &lt;&lt; is already a member of ostream.  What exactly is it talking about?  Am I missing something?</p>
  
  <p>=================================================================</p>
  
  <p>OK, looking back to p. 440:</p>
  
  <blockquote>
    <p>Overloaded operator functions for binary operators can be member functions only when the left operand is an object of the class in which the function is a member.</p>
  </blockquote>
  
  <p>And <code>&lt;&lt;</code> is already a member of <code>ostream</code>, and since redefinition of C++ STL classes is not allowed, <code>&lt;&lt;</code> must be overloaded as a non-member function.  In short, the wording in Deitel's is confusing.</p>