![](/img/trans.png)
[英]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.