In C++ books, array bound must be constant expression, but why the following code works?
<pre><code>#include &lt;iostream&gt;
using namespace std;

int main(){
    int n=10;
    int a[n];

    for (int i=0; i&lt;n; i++) {
        a[i]=i+1;
        cout&lt;&lt;a[i]&lt;&lt;endl;
}
    return 0;
}
</code></pre>

<p>worked fine in Xcode4 under Mac </p>

<p>as said in books, it should be wrong, why?</p>

<p>so confused~</p>
