Proper vector memory management

后端 未结 6 1254
面向向阳花
面向向阳花 2021-02-15 12:08

I\'m making a game and I have a vector of bullets flying around. When the bullet is finished, I do bullets.erase(bullets.begin() + i); Then the bullet disappears. However it doe

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-15 12:30

    I suggest you to take a look at these two idioms and pick the one that fits you the most:
    Shrink to fit
    Clear & minimize

提交回复
热议问题