You're passing AsteroidGen
into the function by value. This means a copy of it is made and the function works on the local copy, which is discarded when the function ends. The asteroid is indeed removed from the list, but from the list stored in the copy.
If you want to modify the AsteroidGen
object in the function, you must pass it by reference:
bool CheckBulletCollision(Lazer lazer, AsteroidGen &asteroids) {
// ... rest of code as before
}