"John Harrison" <jo*************@hotmail.com> wrote in message
news:2t*************@uni-berlin.de...
"lallous" <la*****@lgwm.org> wrote in message
news:2t*************@uni-berlin.de... Hello
Given this:
list<mystruct_t> lst;
lst.push_back(item1);
lst.push_back(item2);
lst.push_back(item3);
Now say I have this:
mystruct_t *p1, *p2, *p3 pointing to item1->item3 memory in side the
list.
If I delete "item2" (or second item) will the other pointers still be
valid?
If you use iterators instead of pointers (like you should) then the C++
standard guarantees that the iterators will remain valid. I don't know
that
the standard guarantees that pointers will be OK, but its very likely to
work.
You mean I change p1, p2, p3 to:
list<mystruct_t>::iterator p1, p2, p3;
then have p1, p2, p3 point to each element, then when any element is deleted
the other iterators are still valid?
--
Elias