I'm getting into C++11 and really can't understand why this happens:
const int arrSource[4] = { 5,7,6,4 };
for (auto& i : arrSource) {
std::cout << i << " ";
++i; //error
}
It says that i
must be a modifiable lvalue and i
: you cannot assign to a variable that is const
.
So it means, that if the arrSource[]
is const
, it makes i
const
too?