在C+書籍中,數(shù)組綁定必須是常量表達(dá)式,但是為什么下面的代碼工作呢?#include <iostream>using namespace std;int main(){
int n=10;
int a[n];
for (int i=0; i<n; i++) {
a[i]=i+1;
cout<<a[i]<<endl;}
return 0;}在mac下的Xcode 4中工作得很好正如書中所說,它應(yīng)該是錯(cuò)誤的,為什么?如此迷茫~
- 3 回答
- 0 關(guān)注
- 709 瀏覽
添加回答
舉報(bào)
0/150
提交
取消