title: how do I initialize a const int member in class constructor
body: <p>I would to initialize a const int member (numGrids) of my class TestCase when I construct a TestCase.  It needs to be const (I think) because it defines the elements of another array member of the classwhich I would also like to initialize when I create a TestCase.  The code is shown below:</p>
  
  <pre>
  /////////////////////////////////////////////////////////////////////////////////////
  
  //TestCase.h
  
  class TestCase
  
  {
  
  protected:
  
      const int numGrids;
  
      Grid meshes[numGrids];
  
  public:
  
      TestCase(const int);
  
  };
  
  
  /////////////////////////////////////////////////////////////////////////////////////
  
  //TestCases.cpp
  
  TestCase::TestCase(const int numGridsSpec)
  
  {
      numGrids = numGridsSpec;
  
      Grid grids[numGrids];
  
  }
  </pre>
  
  <p>I cannot seem to initialize the const member of my class.  I need that member to be constant because it defines the array size of meshes.  I get the following errors:</p>
  
  <pre>
  [ 12%] Building CXX object sources/CMakeFiles/GridRefinementStudy.dir/TestCase.cpp.o
  In file included from /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.cpp:16:0:
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.h:5:12: error: invalid use of non-static data member ‘TestCase::numGrids’
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.h:6:14: error: from this location
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.h:6:22: error: array bound is not an integer constant before ‘]’ token
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.cpp: In constructor ‘TestCase::TestCase(int)’:
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.cpp:25:1: error: uninitialized member ‘TestCase::numGrids’ with ‘const’ type ‘const int’ [-fpermissive]
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.cpp:28:13: error: assignment of read-only member ‘TestCase::numGrids’
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.cpp:29:21: error: no matching function for call to ‘Grid::Grid()’
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/TestCase.cpp:29:21: note: candidates are:
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/Grid.h:13:2: note: Grid::Grid(int, int, double, double)
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/Grid.h:13:2: note:   candidate expects 4 arguments, 0 provided
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/Grid.h:1:7: note: Grid::Grid(const Grid&)
  
  /home/omar/Documents/Programming/C++/FCFD/Current/sources/Grid.h:1:7: note:   candidate expects 1 argument, 0 provided
  
  make[2]: *** [sources/CMakeFiles/GridRefinementStudy.dir/TestCase.cpp.o] Error 1
  
  make[1]: *** [sources/CMakeFiles/GridRefinementStudy.dir/all] Error 2
  
  make: *** [all] Error 2
  </pre>