错误:在C ++ 98模式下不允许基于范围的“for”循环 [英] Error: Range-based 'for' loops are not allowed in C++98 mode

查看:296
本文介绍了错误:在C ++ 98模式下不允许基于范围的“for”循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我按照此页面上的教程:
http://www.cplusplus.com / doc / tutorial / control /
但是我有麻烦做一个range / based for循环。我找到这个页面:
GNU GCC编译器更新答案说我应该打开项目和属性。但是当我尝试时,属性选项是灰色的,没有解释:
http:// imagehack.com/a/img571/4371/xd1x.png
所以..如何激活基于范围/基于循环?

So I'm following the tutorials on this page: http://www.cplusplus.com/doc/tutorial/control/ But I'm having trouble doing a range/based for loop. I found this page: GNU GCC compiler updatingThe answer there says I should open "Project" and "Properties". But when I try that, the "Properties" option is grayed out with no explanation: http://imageshack.com/a/img571/4371/xd1x.png So.. how can I activate range/based for loops?

推荐答案

-std = c ++ 11 标志传递给编译器。当然,GCC应该足够新鲜(> = 4.7)以支持所有这些现代标准。对于CodeBlocks 13.12:设置 - >编译器 - >选项卡编译器标志 - >选项有g ++遵循C ++ 11 ISO C ++ [-std = c ++ 11]

Pass -std=c++11 flag to the compiler. Certainly GCC should be fresh enough (>=4.7) to support all these modern standards. For CodeBlocks 13.12: Settings -> Compiler -> Tab "Compiler Flags" -> Option "Have g++ follow the C++11 ISO C++ [-std=c++11]"

这篇关于错误:在C ++ 98模式下不允许基于范围的“for”循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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