Hello, first of all sorry for my english, I'm french :).
I'm trying to do a little game (with sfml) and I use the container std::map for manage my object. I'm putting in 3 kind of Object: Paddle, Ball and Brick. However I have to put many Brick in my std::map. I did :
1 2 3 4 5 6 7 8 9
Bricks * p_Bricks;
ManagerObj mapManager;
for (unsigned i = 0; i < 5; ++i)
{
p_Bricks = new Bricks();
p_Bricks->setPosition(BrickSeparation, 100);
mapManager.addObj("Brick", p_Bricks);
}
ManagerObj has to arrange the objects for update but I need to stock some different Bricks for delete them one by one. However the pointer address is always the same.
std::map<> does not allow duplicate keys so only one pair with the key "Bricks" is in the map. You can use a std::multimap<> which allows for duplicate keys.