title: Compiler saying variable is not a member of class when it is
body: <p>I'm getting the compiler error "error: wall is not a member of Grid" on the first two lines of the default constructor for grid. I'm not sure why it is saying that as I defined both wall and grid in my header file! I've also tried using this->wall, Grid::wall and an initialization list. Here's the code:</p>
  
  <pre><code>Grid::Grid() {
      this-&gt;wall = Species("wall");
      this-&gt;empty = Species("empty");
      Grid::turn_number = 0;
      int a,b;
      for(a= 0; a &lt; 100; a++)
          for(b = 0; b&lt; 100; b++) {
              Creature empty_creature = Creature(Grid::empty,a,b,NORTH,this);
              ((Grid::map)[a][b]) = empty_creature;
          }
      Grid::width = 0;
      Grid::height = 0;
  }
  </code></pre>
  
  <p>I get the same error when I change my default constructor to use an initialization list:</p>
  
  <pre><code>Grid::Grid()
  : width(0), height(0), turn_number(0), wall("wall"), empty("empty"){
      int a,b;
      for(a= 0; a &lt; 100; a++)
          for(b = 0; b&lt; 100; b++) {
              Creature empty_creature = Creature(Grid::empty,a,b,NORTH,this);
              ((Grid::map)[a][b]) = empty_creature;
          }
  }
  </code></pre>
  
  <p>In the Header file:</p>
  
  <pre><code>class Grid {
  protected:
      Creature map[100][100];
      int width,height;
      int turn_number;
      Species empty;
      Species wall;
  public:
      Grid();
      Grid(int _width, int _height);
      void addCreature(Species &amp;_species, int x, int y, Direction orientation);
      void addWall(int x, int y);
      void takeTurn();
      void infect(int x, int y, Direction orientation, Species &amp;_species);
      void hop(int x, int y, Direction orientation);
      bool ifWall(int x, int y, Direction orientation);
      bool ifEnemy(int x, int y, Direction orientation, Species &amp;_species);
      bool ifEmpty(int x, int y, Direction orientation);
      void print();
  };
  </code></pre>
  
  <p>Here's the rest of my compiler errors (asked for in comments). Sorry for the formatting, my computer spits out weird characters for some reason.</p>
  
  <pre><code>Darwin.c++: In constructor â€˜Grid::Grid()â€™:
  Darwin.c++:8:40: error: class â€˜Gridâ€™ does not have any field named â€˜wallâ€™
  Darwin.c++:8:54: error: class â€˜Gridâ€™ does not have any field named â€˜emptyâ€™
  Darwin.c++:12:39: error: â€˜emptyâ€™ is not a member of â€˜Gridâ€™
  Darwin.c++: In constructor â€˜Grid::Grid(int, int)â€™:
  Darwin.c++:17:86: error: class â€˜Gridâ€™ does not have any field named â€˜wallâ€™
  Darwin.c++:17:99: error: class â€˜Gridâ€™ does not have any field named â€˜emptyâ€™
  Darwin.c++:21:39: error: â€˜emptyâ€™ is not a member of â€˜Gridâ€™
  Darwin.c++: In member function â€˜void Grid::addWall(int, int)â€™:
  Darwin.c++:32:31: error: â€˜wallâ€™ is not a member of â€˜Gridâ€™
  Darwin.h:35:10: error: field â€˜emptyâ€™ has incomplete type
  Darwin.h:36:10: error: field â€˜wallâ€™ has incomplete type
  In file included from RunDarwin.c++:33:0:
  Darwin.h:35:10: error: field â€˜emptyâ€™ has incomplete type
  Darwin.h:36:10: error: field â€˜wallâ€™ has incomplete type
  </code></pre>