title: Can't Overload operator<< as member function
body: <p>I am trying to overload <code>operator&lt;&lt;</code> as a member function. It works if simply do this:</p>
  
  <p><code>friend ostream&amp; operator&lt;&lt;(ostream&amp; os, const MyClass&amp; myClass);</code> in my header file and in my MyClass.cc file:</p>
  
  <pre><code>ostream&amp; operator&lt;&lt;(ostream&amp; os, const MyClass&amp; myClass)
  {
     return myClass.print(os);
  }
  </code></pre>
  
  <p>However, if I try to take the <code>friend</code> off and make it a member function, then it complains that <code>operator&lt;&lt;</code> can only take one argument. Why?</p>
  
  <pre><code>ostream&amp; MyClass::operator&lt;&lt;(ostream&amp; os, const MyClass&amp; myClass)
  {
     return myClass.print(os);
  }
  </code></pre>
  
  <p>I read at <a href="https://stackoverflow.com/a/1906474/195488">this question</a> that it can't be a member function, but not sure why?</p>