Call private member within the method belonging to the class itself
<p>I encountered this problem when implementing a class:</p>

<pre><code>class Cell {
     bool isAlive;
     int numNeighbours;
     //...omit irrelavent private members



     public:
         Cell();  // Default constructor
         ~Cell(); // Destructor


      void setLiving();   

     ....         
    };
    void Cell::setLiving(){
         isAlive=true;
       }


 class Grid{...
  friend std::ostream&amp; ::operator(std::ostream&amp; out, const Grid &amp;g);
  };//...omit

 std::ostream&amp; ::operator&lt;&lt;(std::ostream &amp;out, const Grid &amp;g){
 int i,j;
 for(i=0;i&lt;g.gridSize;i++){
   for(j=0;j&lt;g.gridSize;j++){
         if(**g.theGrid[i][j].isAliv*e*) out&lt;&lt;"X";
         else out&lt;&lt;"_";
    }
    out&lt;&lt;endl;
   }
    return out;
  }
</code></pre>

<p>The complier said that "isAlive" is a private member so I can't call it that way
I think the problem is at "g.theGrid[i][j].isAlive"
I tried to friend class Grid but it didnt help</p>
