I am trying to learn vectors; it uses confusing a ranged loop.
I Don’t understand how const int& i works in tandem with the single colon ‘:’ and vector1.
for (const int& i : vector1)
{
cout << i << " ";
}
>Solution :
As of C++11, this is available. It is a range-based for loop.
In your example, i is a const reference to each item in vector1 in turn.