It is called range loop.
int arr[] = { 1, 2, 3 };
for (int val : arr)
cout << val;
works the same as:
int arr[] = { 1, 2, 3 };
for (int i=0;i<sizeof(arr)/sizeof(int);i++)
{
int val=arr[i];
cout << val;
}
But range loop can do far more.
It simply means loop through all members. Keep in mind some classes can have a complicated iterator and a range for
runs through an array in a clean way. Also, notice it is a c++11
feature.