title: How to properly overload the << operator for an ostream?
body: <p>I am writing a small matrix library in C++ for matrix operations. However my compiler complains, where before it did not. This code was left on a shelf for 6 months and in between I upgraded my computer from debian etch to lenny (g++ (Debian 4.3.2-1.1) 4.3.2
  ) however I have the same problem on a Ubuntu system with the same g++.</p>
  
  <p>Here is the relevant part of my matrix class:</p>
  
  <pre><code>namespace Math
  {
      class Matrix
      {
      public:
  
          [...]
  
          friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; stream, const Matrix&amp; matrix);
      }
  }
  </code></pre>
  
  <p>And the "implementation":</p>
  
  <pre><code>using namespace Math;
  
  std::ostream&amp; Matrix::operator &lt;&lt;(std::ostream&amp; stream, const Matrix&amp; matrix) {
  
      [...]
  
  }
  </code></pre>
  
  <p>This is the error given by the compiler:</p>
  
  <blockquote>
    <p>matrix.cpp:459: error: 'std::ostream&amp;
    Math::Matrix::operator&lt;&lt;(std::ostream&amp;,
    const Math::Matrix&amp;)' must take
    exactly one argument</p>
  </blockquote>
  
  <p>I'm a bit confused by this error, but then again my C++ has gotten a bit rusty after doing lots of Java those 6 months. :-)</p>