Yes, you get the same problem with std::vector because it may move objects when it needs more memory.
There are several solutions:
- store pointers instead of objects (so that only the pointer values move in memory, not the objects themselves)
- use std::list, which never invalidates its elements
- link sprites to textures after the entire container is filled, so that they are at their final location in memory
- handle copy correctly inside the CMap class -- look at the last section of the sprite tutorial