auto 关键字在 Dev C++ 中不起作用 [英] auto keyword not working in Dev c++

查看:39
本文介绍了auto 关键字在 Dev C++ 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我编写的代码,用于查看 auto 关键字如何工作,但它没有在 Dev C++ 中编译,并给出以下警告:[警告] C++11 自动仅适用于 -std=c++11 或 -std=gnu++11如何克服这个故障并按照警告的指示去做?

This was a code I wrote to see how auto keyword works but it didn't got compiled in Dev C++ and gave the following warning: [Warning] C++11 auto only available with -std=c++11 or -std=gnu++11 How to overcome this glitch and do what the warning tells to do?

#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 可以在这里找到:如何从 c++98 模式更改模式Dev-C++ 到支持 C++0x(基于范围)的模式?

You need to enable c++11 in the compiler using the switch instructions can be found here: How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?

这篇关于auto 关键字在 Dev C++ 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆