像这样的 C++教程说,所有数组的大小必须在程序运行之前确定.例如,这是不允许的:
cout << "How many variables do you want? ";
int nVars;
cin >> nVars;
int anArray[nVars]; // wrong! The size of the array must be a constant
Run Code Online (Sandbox Code Playgroud)
但这个简单的程序确实可以编译和执行.应该吗?