title: C++ overload << (invalid use of non static member)
body: <p>The problem is that I want output of my program using</p>
  
  <pre><code>Ackermann&lt;M,N&gt;::wartosc;
  </code></pre>
  
  <p>i wanted to do it by overload operator &lt;&lt;, but when just in main i can type</p>
  
  <pre><code>cout &lt;&lt; Ackermann&lt;M,N&gt;::wartosc;
  </code></pre>
  
  <p>there is a problem too.</p>
  
  <p>here is my code</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  template&lt;int M, int N&gt;
  class Ackermann {
      private:
          int n0, m0; 
  
          int count(int m, int n)
          {
              if ( m == 0 ) return n+1;
              else if ( m &gt; 0 &amp;&amp; n == 0 ){ return count(m-1,1);}
              else if ( m &gt; 0 &amp;&amp; n &gt; 0 ) { return count(m-1,count(m,n-1));}   
              return -1;      
          }   
      public:
  
          Ackermann()
          {
              n0 = N;
              m0 = M;
          }
  
          int wartosc()
          {
              return count(m0,n0);
          }               
  
          template&lt;int M1, int N1&gt;
          friend ostream &amp; operator&lt;&lt; (ostream &amp;wyjscie, const Ackermann&lt;M1,N1&gt; &amp;s); 
  };
  
  
  template&lt;int M, int N&gt;
  ostream &amp; operator&lt;&lt; (ostream &amp;output, const Ackermann&lt;M,N&gt; &amp;s)         
   {
      return output &lt;&lt; Ackermann&lt;M,N&gt;::wartosc;
   }
  
  
  int main()
  {
      Ackermann&lt;3, 3&gt; function;
  
      cout &lt;&lt; function &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>and the error is </p>
  
  <pre><code>ack.cpp:38:36: error: invalid use of non-static member function ‘int Ackermann&lt;M, N&gt;::wartosc() [with int M = 3, int N = 3]’
  </code></pre>