title: enum type value as the length of a array in C++
body: <p>As we all know, the array length in C++ must be determined. Then we can use:</p>
  
  <pre><code>const int MAX_Length=100;
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>#define MAX_LENGTH 100
  </code></pre>
  
  <p>to determined the length of an array before compilation. But, when I read the book c++ primer by lippman, in chapter 3.5.1 in 5th Edition, it says: the length of an array must be an constant expression. Then the problem comes:</p>
  
  <pre><code>typedef enum Length{LEN1=100, LEN2, LEN3, LEN4}LEN; 
  LEN MAX_Length=LEN2;  //101
  int iArray[LEN2];     //attention
  </code></pre>
  
  <p>the code compiled successfully in mingw32-g++. But failed in VS2008, and the errors are:</p>
  
  <pre><code>error C2057: expected constant expression
  error C2466: cannot allocate an array of constant size 0
  error C2133: 'iArray' : unknown size
  </code></pre>
  
  <p>And I think the enum value is constant, so it should be used as an array's length. right?</p>
  
  <p>I am confused, could you help me? Thank you.</p>