I'm using code::blocks w/ minGW.
I get an error message at the first for statement
for(int& n : arr)
Is this an issue with the compiler not being c++0x compliant?
I'm using code::blocks w/ minGW.
I get an error message at the first for statement
for(int& n : arr)
Is this an issue with the compiler not being c++0x compliant?
No, it's a problem with you not making a proper for loop.Everything in this color is optional, everything in bold is not.Code:for( initialize_stuff ; truth_test_to_continue_or_not ; increment_stuff ) { do_stuff(); }
Quzah.
Last edited by quzah; 08-03-2011 at 09:11 PM. Reason: semi-colons don't take bolding well
Hope is the first step on the road to disappointment.
Yes.Originally Posted by tabl3six
Hence the mention of C++0x, or rather C++11. Refer to clause 6.5.4.Originally Posted by quzah
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I don't have the C++ standard. Did they suddenly decide you don't need to form proper loops? I knew there was a reason I didn't like C++. Looks like they just gave me another one.
Quzah.
Hope is the first step on the road to disappointment.
I just referred to one of the latest draft versions; the final version has not been published yet (I think), and I don't have my copy of the final draft with me.Originally Posted by quzah
It certainly is not "suddenly", and it is a proper loop since the language defines what a proper loop is. Basically, it is syntactic sugar for a typical for loop that iterates over some array or container via iterators.Originally Posted by quzah
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Refer to clause 6.5.4.
Where do I find this?
In the (yet to be published) 2011 edition of the C++ standard. You can find draft versions at the C++ standards committee website.Originally Posted by tabl3six
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Bear in mind that the version of MinGW available in C::B may be a few steps behind the original MinGW port, which in turn may be a few steps behind the current GCC release.
At a command prompt, type
$ gcc --version
and check to see what is supposed to be supported at that version (check the main GCC site).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
as salem said, you need to check the version of g++ that you have. 4.6 is the earliest version that supports range-based for, and on a side note, the nullptr keyword.
I've searched for the 4.6 compiler. Doesn't seem to exist. I went to the GCC website and saw a link for it there, but the information is so overwhelming, not sure what to do.
I would think the author of the book wouldn't put examples of code you couldn't easily run. This seems like pulling teeth to me.
Think I'm going to ignor the C++0x chapter.
I don't know if this will work, but have you tried:
Settings -> compiler and debugger -> global compiler settings
In the "compiler flags" tab, there is an option that says, "Have g++ follow the coming C++0x ISO c++ language standard"
Perhaps enabling this option will help?
I doubt that will help unless the OP upgrades the compiler to version 4.6 or higher. The newest compiler I found on the MinGW site was version 4.52.
Jim