Don't recognise this for loop
Hi, I was going through Bjarne's book (Principles and Practice using C++ 2nd Ed.) and came across this for loop:
1 2 3
|
double sum = 0;
for(int x : temps)sum += x; //where 'temps' is a vector of type double
cout << "Average temperature: " << sum/temps.size() << '\n';
|
I just haven't seen the structure of this for loop before, and it doesn't explain the syntax as before he did with the usual for(;;).
Don't suppose anyone could help explain this?
Thanks in advance, Jack.
Ahh, thank you very much JLBorges.
Topic archived. No new replies allowed.