Proper vector memory management

后端 未结 6 1155
情歌与酒
情歌与酒 2021-02-15 11:56

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:21

    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

提交回复
热议问题