int a[] = {1,2,3,4};
vector<int> v(a, a + sizeof(a) / sizeof(int) ); // v:1 2 3 4
for(vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
if (*it == 2)
v.insert(v.begin(), 0); // v:0 1 2 3 4
}
The question is after the insertion, does it
still point to 2
? or change to 1
? or anything else? I got a really weird output and couldn't figure out.
Thank you!