<分区>
我已经从这里阅读了这一段:http://www.cplusplus.com/doc/tutorial/dynamic/
You could be wondering the difference between declaring a normal array and assigning dynamic memory to a pointer, as we have just done. The most important difference is that the size of an array has to be a constant value, which limits its size to what we decide at the moment of designing the program, before its execution, whereas the dynamic memory allocation allows us to assign memory during the execution of the program (runtime) using any variable or constant value as its size.
但是我的这段代码工作得很好:
int number;
cin>>number;
int myArray[number];
cout<<sizeof(myArray)/sizeof(myArray[0])<<endl;
cout<<sizeof(myArray)<<endl;
这是否意味着数组是在动态内存中创建的?或者它是在静态内存中创建的,但它的大小仍然在运行时确定?