[英]Debug C++ Standard Library with Visual Studio Code on macOS
[英]C++ Standard Template Library simple code giving error in vs code in macos mojave
我在 vs 代码编辑器中的 c++ 中的 STL 中工作,我已经声明了一个数组,如下面的代码中给出的......
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<int> arr={11,2,13};
for(int i=0;i<3;++i)
cout<<arr[i]<<" ";
return 0;
}
我收到无法使用初始化列表初始化非聚合类型向量的错误。 当我在 Clion ide 中编译代码时,它工作正常。 那么vs代码有什么问题呢?
看来编译器不支持 c++11。
您可以使用-std=c++11
再试一次。
例如。 g++ -std=c++11 -c example.cpp
并且还可以获得更多信息, 为什么我会得到“非聚合不能用初始化列表初始化”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.