我有 Eclipse Juno C++(内部版本号:20120614-1722)。我正在尝试使用指令 -std=c++11 或 -std=c++0x 设置编译器调用参数,但同时编译下面的代码。Eclipse Juno 中没有“工具设置”(至少对于 Mac),所以我无法转到“C/C++ 构建 -> 设置 -> 工具设置”。我的编译器是 GCC 4.8.0
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(void) {
vector<string> v = {"a","b","c"};
for(string s: v){
cout << s << endl;
}
return 0;
}
我有:
HelloWorld.cpp:16:33: error: could not convert ‘{"a", "b", "c"}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<std::basic_string<char> >’
HelloWorld.cpp:17:16: error: range-based ‘for’ loops are not allowed in C++98 mode