title: static constant members for array size
body: <p><strong>MyClass.h</strong></p>
  
  <pre><code>class MyClass
  {
  public:
  
  static const int cTotalCars;
  
  private:
  
  int m_Cars[cTotalCars];
  };
  </code></pre>
  
  <p><strong>MyClass.cpp</strong></p>
  
  <pre><code>#include "MyClass.h"
  const int MyClass::cTotalCars = 5;
  </code></pre>
  
  <p>The above code doesn't work because it will say "expected constant expression" for the m_Cars array.</p>
  
  <pre><code>class MyClass
  {
  public:
  
  static const int cTotalCars = 5;
  
  private:
  
  int m_Cars[cTotalCars];
  };
  </code></pre>
  
  <p>The above will work, but I am told that I should always define static members in the CPP file, outside the class definition. What can I do?</p>