for loops
I found this example in the link:
http://www.cplusplus.com/doc/tutorial/arrays/
at the bottom of the page.
#include <iostream>
using namespace std;
int main()
{
int myarray[3] = {10,20,30};
for (int i=0; i<3; ++i)
++myarray[i];
for (int elem : myarray) //I don't understand this line
cout << elem << '\n';
}
when I tried to run it ,I got an error due to the for (int elem : myarray)
is it a mistake in the example
Thank you
Last edited on
It's a new feature that was added in C++11. If you have an old compiler it will not work.
Topic archived. No new replies allowed.