c++ 11 vs 98

so recently i used a for loop,that a person from this forum showed me


for(char c:str)

this gave me the compile error ranged loops not allowed in c++ 98 or smth
now my question is,why is an older version of c++ the default?
is it not safe to use the 11 version?
should i switch back or should i continue coding in c++11 standard?
Last edited on
> why is an older version of c++ the default?

Depends on the compiler vendor.

For instance, the older version is not the default with the current Microsoft compiler (in fact, the older version is not even available).

The older version is the default with the GNU compiler. (Linux has a lot of 'current' legacy code, I suppose).
i guess its the default in code blocks.
still though
should i use it or switch back?
You should always use the latest standard. They don't add new features to the language to make it worse.

As of this post, the latest standard is C++14
Last edited on
If you are learning C++, or writing fresh code, use the current standard, not the superseded one.
-std=c++11 -Wall -Wextra -pedantic-errors

If you have legacy code that breaks with C++11, you may want to use the older standard till it is cleaned up.
(In some scenarios, you may want to use an older version of the compiler.)
alright thank you!
The GNU people think that you should have to specifically initiate C++11 support because, they argue, the compiler doesn't completely support the C++11 standard.

Which is nonsense, because (1) people want whatever C++11 features they can get, (2) GCC supports a very large subset of the same desired features available in other C++11 compilers, (3) they had no such compunction when C+98 was standardized.

You can tell C::B how to make GCC behave following instructions here:
http://stackoverflow.com/a/24398366/2706707

Hope this helps.
Topic archived. No new replies allowed.