Y
Yngve
Hi!
I have a (newbie) problem wich i would become glad if someone could help me
with.
I have a Vector of pointers to instances of another class. I would like to
remove a position in the middle of the vector. I am not using iterators at
the moment, but if i had i think that i could have used "erase".
This is my code now:
// ------------------------------
// Go through all the elements in my vector, increase iPos as we go
for (unsigned int iPos = 0 ; iPos < vPosList.size() ; iPos++) {
// Check if the position vPosList[iPos] is att coordinate iX,iY
if( vPosList[iPos]->equalPos(iX, iY) == true ) {
delete vPosList[iPos]; // Remove the object
// Here i would like to remove the element in the vector
// so that i don´t get a spot wich points to a non existing
// object --> crash..
}
}
I have a (newbie) problem wich i would become glad if someone could help me
with.
I have a Vector of pointers to instances of another class. I would like to
remove a position in the middle of the vector. I am not using iterators at
the moment, but if i had i think that i could have used "erase".
This is my code now:
// ------------------------------
// Go through all the elements in my vector, increase iPos as we go
for (unsigned int iPos = 0 ; iPos < vPosList.size() ; iPos++) {
// Check if the position vPosList[iPos] is att coordinate iX,iY
if( vPosList[iPos]->equalPos(iX, iY) == true ) {
delete vPosList[iPos]; // Remove the object
// Here i would like to remove the element in the vector
// so that i don´t get a spot wich points to a non existing
// object --> crash..
}
}