🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

C++ Delete An Enemy from a Vector

Started by
11 comments, last by Alberth 3 years, 2 months ago

alvaro said:

That's not at all the kind of thing I was talking about. Is the sf:: stuff important for your question? Can you make a tiny program that outputs something to standard out and still exhibits the relevant problem? Can you then post the entire program here so we can reproduce the problem ourselves?

as i said above i have problems with this code:

if (enemies1.empty()){

enemies1.erase(std::remove_if(enemies1.begin(), enemies1.end(), [sprite](const std::unique_ptr <enemy> &e) { return e->rect.getGlobalBounds().intersects(sprite.getGlobalBounds()); }), enemies1.end());

}

its not erasing last element of vector. i would like to erase enemies from my class this is my problem

Advertisement

yusufabi said:
its not erasing last element of vector. i would like to erase enemies from my class this is my problem

Please explain in words how this erase code works.

This topic is closed to new replies.

Advertisement