title: Finding the mistake in C++ operator overloading
body: <p>I am trying to understand how to overload the '&lt;&lt;' operator. So i wrote a simple test code that I report part of if here:</p>
  
  <pre><code>class Buffer {
  
      vector&lt;char&gt; buffer;
  
      ...
  
      ostream&amp; operator&lt;&lt; (ostream&amp; out, const vector&lt;char&gt;&amp; v) {
              out &lt;&lt; "[";
              size_t last = v.size() - 1;
              for(size_t i = 0; i &lt; v.size(); ++i) {
                  out &lt;&lt; v[i];
                  if (i != last)
              out &lt;&lt; ", ";
              }
              out &lt;&lt; "]";
              return out;
      }
  
      ...
  
  };
  </code></pre>
  
  <p>The way I use the class in the main is the usual but I get the following error. Why?</p>
  
  <pre><code>main.cpp:22:10: error: overloaded 'operator&lt;&lt;' must be a binary operator (has 3 parameters)
  ostream&amp; operator&lt;&lt; (ostream&amp; out, const vector&lt;char&gt;&amp; v) {
           ^
  </code></pre>