In my code a have a global vector of Node object and a local vector of Node pointers:
#include
#include
#include
You have stumbled upon one of the great known "dark corners" of C++: the great "iterator invalidation." Definitely familiarize yourself intimately with this:
Iterator invalidation rules
In particular, you are hitting this reality:
vector: all iterators and references before the point of insertion are unaffected, unless the new container size is greater than the previous capacity (in which case all iterators and references are invalidated) [23.2.4.3/1]
(the emphasis is mine)
Now, about your issue. You can either make sure the vector never re-allocates. Or, you can use a different container that does not have this issue. There are compromises among all the container types, depending on your needs. Check out the other question thoroughly and make an informed decision.