Arrays.

I know what this does, but i don't understand how it does it.
1
2
3
4
5
int nArray[128];
for(int& n: nArray)
{
n = 0;
}

I understand that n is being referenced to the value of the array, but i don't understand what this ":" is for. Does the for loop say : Reference n to every value of the array and when you are done stop? If i am understanding this wrong please explain it to me and give me some other examples. Thank you in advance.
That's just syntax for the range-based for-loop. It works on arrays with known bound and anything with begin() and end() functions. It's shorthand for iterators.
Topic archived. No new replies allowed.