Change code to
BOOST_FOREACH(node*& n, vector_of_nodes){
if (n->get_id() < 100)){
n = new node(last_id++);
n->add_related_node(other_node);
dfg->add_node(n);
}
}
since in your version you change address of local pointer. And, before you use n = new node
, why you don't delete old? Since you have problems with manual managing of resources, why you don't use smart pointers
?