title: 'variable name' cannot appear in a constant expression c++
body: <p>Anyone have any clue what this error might actually mean? I'm tripping on a bit of code that can't seem to get around it. I've tried it with just h*2 instead of hprime, and just w*2 instead of wprime. Every time I get the same compiler (g++ compiler) error of : </p>
  
  <p>grid.cpp: In constructor ‘Grid::Grid(int, int)’:</p>
  
  <p>grid.cpp:34: error: ‘hprime’ cannot appear in a constant-expression</p>
  
  <p>(the compiler doesn't always say hprime, it will say whatever variable is there, be it h or hprime or width). Any help would be greatly appreciated!<br></p>
  
  <pre><code>class Grid
  {
      public:
      Grid(int x, int y);
      ~Grid();
  
      void addObstacle(int w, int h);
      void toString();
  
      int** grid;
      int height;
      int width;
  
  };
  
  Grid::Grid(int w, int h)
  {
      width = w;
      height = h;
      const int hprime = h*2;
      const int wprime = w*2;
      grid = new int[wprime][hprime];
  
      for(int x=0;x&lt;wprime;x++) {
          for (int y=0; y&lt;hprime;y++) {
              grid[x][y] = 0;&lt;br&gt;
          }
      }
  }
  </code></pre>