小编Dim*_*ons的帖子

为什么不能在C ++中使用变量作为数组大小?

根据我的C ++教科书,以下表达式:

cout << "Enter number of students\n";
cin >> number;
int score [number];
Run Code Online (Sandbox Code Playgroud)

是ILLEGAL表达式。我不能使用变量作为数组大小。

我为什么不能这样做?(我不是在寻找替代方法,我还没有深入研究指针,向量等,但是我想了解这种行为。)

c++ arrays

3
推荐指数
1
解决办法
1573
查看次数

标签 统计

arrays ×1

c++ ×1