I try to set vector of pointers to int to elements of another vector
The second time you push back an element into the vector
vecInt, the capacity of the vector changes. New area of twice the size is allocated and hence the old pointer starts pointing to something else. Basically, whenever the size of the vector reaches its capacity, reallocation of the vector has to happen and it invalidates all pointers referring to the elements in the sequence.
Have a look at When does a std::vector reallocate its memory array?