这是我编写的代码,用于查看 auto
关键字如何工作,但它没有在 Dev C++ 中编译并给出以下警告:
[警告] C++11 自动仅适用于 -std=c++11 或 -std=gnu++11
如何克服这个故障并按照警告的指示去做?
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
std::vector<auto> v={2,-1,4,6,7};
auto beg = v.begin();
while (beg != v.end())
{
++beg;
cout<<beg;
}
}
最佳答案
您需要使用 switch 指令在编译器中启用 c++11 可以在这里找到:How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?
关于c++ - auto 关键字在 Dev C++ 中不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45387292/