title: Overloaded operator, but still "no match for operator" error
body: <p>I have a class that overloads the output operator "&lt;&lt;", and I have implemented it as such. However, the compiled complains about "no match for operator &lt;&lt;.." in the main method. I have no idea why it's not working.</p>
  
  <pre><code>/*
   * Accumulator.cpp
   *
   *  
   *      
   */
  #include &lt;iostream&gt;
  #include "Accumulator.h"
  
  using namespace std;
  
  
  Accumulator::~Accumulator() {
      // TODO Auto-generated destructor stub
  }
  
  void Accumulator::operator+=(const int nbr) {
      nbrs.push_back(nbr);
  }
  
  void Accumulator::undo() {
      if (!comitted) {
          nbrs.pop_back();
      }
  }
  
  void Accumulator::commit() {
      lastCommit = nbrs;
      comitted = true;
  }
  
  void Accumulator::rollback() {
      nbrs = lastCommit;
  }
  
  ostream&amp; Accumulator::operator&lt;&lt;(ostream &amp;out, const Accumulator &amp;accum){
      int sum = 0;
      for(int nbr : nbrs){
          sum+= nbr;
      }
      out &lt;&lt; sum;
      return out;
  }
  int main() {
      Accumulator accum;
      char cmd;
      while (cin &gt;&gt; cmd) {
          switch (cmd) {
          case 'p':
          cout &lt;&lt; "Sum is now " &lt;&lt; accum &lt;&lt; endl;
          break;
          case 'a': {
              int nbr;
              cin &gt;&gt; nbr;
              accum += nbr;
              break;
          }
          case 'u':
          accum.undo();
          break;
          case 'c':
          accum.commit();
          break;
          case 'r':
          accum.rollback();
          break;
      }
  }
  }
  </code></pre>