<分区>
我对动态内存分配有点困惑,我希望有人能帮我解决这个问题。
假设我们有一个程序:
int length = 0;
cout << "Enter the size of the array" << endl;
cin >> length;
cin.ignore();
int numbers[length];
Wouldn't this still be dynamic memory allocation since the array size is being defined at runtime after the user enters in the specified length?
与使用:
int numQuestions = 0;
cout << "How many questions would you like to add?" << endl;
cin >> numQuestions;
cin.ignore();
Question *newQuestions = new Question[numQuestions];