For the two snippet of code, i don't understand the second one
1st: it prints 0 1 2 as expected
vector<int> ivec;
ivec={0,1,2};
for(auto i: ivec){
cout<<ivec[i]<<endl;
}
2nd: it prints 0 0 0 5. How is this random value generated?
vector<int> ivec;
ivec={0,1,2};
ivec={4,5,9,1};
for(auto i: ivec){
cout<<ivec[i]<<endl;
}