J
JackC
Hi,
I am trying to find if its at all possible to create a pointer to an
object inside a vector, based upon a vector iterator that will remain
a valid pointer once the iterator is invalid.
For example I just tried:
for(vector<ship>::iterator invader = shooters.begin(); invader !=
shooters.end(); )
{
....
Ship.parent = &(*invader);
....
}
With the aim being that parent points to the item inside the invader
vector throughout the life of the vector, but instead the pointer
becomes invalid when the iterator is invalidated.
Any solutions to this problem?
Thanks
Jack
I am trying to find if its at all possible to create a pointer to an
object inside a vector, based upon a vector iterator that will remain
a valid pointer once the iterator is invalid.
For example I just tried:
for(vector<ship>::iterator invader = shooters.begin(); invader !=
shooters.end(); )
{
....
Ship.parent = &(*invader);
....
}
With the aim being that parent points to the item inside the invader
vector throughout the life of the vector, but instead the pointer
becomes invalid when the iterator is invalidated.
Any solutions to this problem?
Thanks
Jack