C++的数组可以int n;cin>>n;int a[n];这样初始化吗?
天蓬老师
天蓬老师 2017-04-17 14:29:46
0
2
1171

如题,

 `int n;
  cin>>n;
  int a[n];

c++可不可以这样初始化数组啊,在VS2010中不可以,在devc++(编译器gcc) 中可以。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
Peter_Zhu

This is the variable length array VLA in the C language C99 standard, which is not supported by the C++ standard. The gcc compiler supports variable-length arrays, but the vc compiler does not. Search for variable length arrays. There will be a lot of information on this (in Chinese and English). Stroustrup, the father of C++, talked about variable-length arrays on his website. There is a short paragraph. If you are interested, you can check it out http://www.stroustrup.com/bs_...

小葫芦

C++ does not support variable length arrays, C supports it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template