When I try to compile the example program in the tutorial for creating a range-based for loop, I get an error: 10 16 C:\Users\Public\Documents\C prog source\range based for loop.cpp [Error] range-based 'for' loops are not allowed in C++98 mode. Is this sample program supposed to work?
Shows just how ignorant I am. I did not realize that there was a g++. No I am using the compiler that came with dev-cplusplus compiler that I downloaded from the net. And I thought this forum was for Cplusplus users.
Yes, this forum is for helping with learning C++ :)
Shows just how ignorant I am.
Everyone learns what a compiler is at some point once they begin their journey to becoming a programmer.
In dev-cplusplus:
Go to Tools -> Compiler Options -> "Compiler" tab
Check the checkbox labeled, "Add the following commands when calling the compiler" And add in the text entry box, "-std=c++11" or if that doesn't work "-std=C++0x"
Should be something like that anyway, I haven't had Dev C++ installed for many years, so I had to look at some screenshots on Google to remember.
hautry
One aspect to also consider if you have the facilities available, is to use a more up to date and supported IDE rather than dev C++ such. as visual studio, code blocks, Xcode, Qt creator which are way ahead. Each of those wil virtually automatically give you the ability and choice to use the various forms of C++ mentioned elsewhere here. I realise some schools in different parts haven't updated from Dev so students are stuck.