title: cannot access private members in friend ostream
body: <p>I tried to make friend <code>ostream</code> function. The compiler say i cannot access private member of the class, even though i declared it as <code>friend</code>. I read a similar question and it say the problem is with the namespcaes.(the question: <a href="https://stackoverflow.com/questions/15731414/c-friend-function-cant-access-private-members">C++ friend function can&#39;t access private members</a>)</p>
  
  <p>My Code is below:</p>
  
  <p>header:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  //using namespace std;
  
  namespace biumath
  {
  #ifndef BIUMATH_H
  #define BIUMATH_H
  class Assignment
  {
  private:
      int **m_varArray;
      int m_rowsOfVarArray;
  public:
       Assignment(); //1
       Assignment(char symbol, double value); //2
       bool containsValueFor(char symbol) const; //3
       double valueOf(char symbol) const; //4
       void add(char symbol, double val); //5
       friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, 
       const Assignment&amp; assignment);
  };
  }
  #endif
  </code></pre>
  
  <p>cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "biumath.h"
  using namespace biumath;
  using std::cout;
  using std::endl;
  
  ostream&amp; operator&lt;&lt; (ostream&amp; out, 
       const Assignment&amp; assignment){
          out&lt;&lt;assignment.m_rowsOfVarArray&lt;&lt;std::endl;
          //return the stream. cout print the stream result.
          return out;
  }
  </code></pre>