iT邦幫忙

0

模稜兩可

#

#include
using namespace std;

int count = 0;
int main()
{
cout << count;
}

vs說count模凌兩可error
dev可以跑

還有像這個也是
int n=100;
int a[n]
vs都不能用,為什麼?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

1
微甜的酸
iT邦新手 2 級 ‧ 2020-11-07 14:12:28

很簡單,這跟C++的歷史沿革有關。
因為直到C++11(也就是2011年的版本),陣列的大小必須是個常量表達式。
請改用最新版的C++或是使用GCC編譯器。

int n = 10;
a[n];

是說你的include沒有東西ㄟ?u?
還有下次請你將你的程式碼前後用三個(`)包起來,在(ESC)的下方。

0
EricChu
iT邦新手 4 級 ‧ 2020-11-08 08:39:39
#include <iostream>

才對

我要發表回答

立即登入回答