In for(auto a:b), b is a container. The effect is to use a to traverse and obtain each value in the b container, but a cannot affect the elements in the b container.
For (auto & a: b) is added a reference symbol, you can assign a value to the content in the container, you can fill the content of the container b by assigning a value to a.
int arr[10];
for(int i=0;i<10;i++)
{
arr[i]=i;
}
for(auto &a:arr)
{
std::cout << a;
}
Output results 1-9