I just inserted into a vector and all is well, when I went to insert next, with the vector iterator currently pointing at vectorname.begin(). Since I only have one value, the guard I have should stop it from iterating, but it breaks for some reason. I feel like I’m not accessing the end correct, or stopping the iteration.. either way, here’s the code that’s breaking.
// check if iterator X and Y are equal to destX and destY
if(iter != this->playerVector.end())
{
while((iter->myX != destX) && (iter->myY != destY) || (iter != this->playerVector.end()))
{
iter++;
}
}
it breaks when checking the while statements after one iteration.
It seems you are missing proper conditioning in the
whileloop and that’s why it’s alwaystrue(also put braces when you have various operators in place). Your condition should be,Following is another simple version of your
whileloop: