title: Accessing a private data member from within a member function
body: <p>In a file named maze.hpp (a header file) I have the following:</p>
  
  <pre><code>class Maze
  {
      public:
          Maze(int size);
          ~Maze() {}
  
          void step();
  
      private:
  
          int exitRow;    
  };
  </code></pre>
  
  <p>In another file named maze.cpp I have the following:</p>
  
  <pre><code>void step(){
  
      this.exitRow = 3;
  
  }
  
  int main(){
      Maze maze(4);
      maze.step();
  }
  </code></pre>
  
  <p>This gives an error: <code>invalid use of 'this' outside of a non-static member function</code></p>
  
  <p>step is a member function of <code>Maze</code>. How can I access the data members of an instance of <code>Maze</code> from within one of its member functions?</p>