I try to set vector of pointers to int to elements of another vector
vector<int> vecInt;
vector<int*> vecPInt;
int main()
{
vecInt.push_back(1);
vecPInt.push_back(&vecInt[0]);
vecInt.push_back(1);
vecPInt.push_back(&vecInt[1]);
for(auto v:vecInt)
{
cout<<v<<"\n";
}
for(auto v:vecPInt)
{
cout<<*v<<"\n";
}
}
but the result is
1
1
11717664
1
There are another way to do this. But why in this case this is the behaviour?