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

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

问题描述

因此,我正在遵循此页面上的教程: http://www.cplusplus.com/doc/tutorial/control/但是我在做范围/基于for的循环时遇到了麻烦.我找到此页面: GNU GCC编译器更新那里的答案说我应该打开项目"和属性".但是,当我尝试这样做时,属性"选项显示为灰色,没有任何解释: http://imageshack.com/a/img571/4371/xd1x.png所以..如何激活范围/基于for的循环?

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模式下不允许循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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