Hi,
Not sure if I'm doing something stupid here or not, I want a map of integers and objects (Rooms) which I've done, but whenever I create a new room to add to the map it appears to use the same memory location as the previous Room(s). The upshot being I have a map of n 'Rooms' but they're all the same object.
Code:
void CMazeBuilder::BuildRoom(int rid, string desc) {
Room * room = new Room(desc);
cout<<"New Room Made: "<<room->getDescription()<<endl;
cout<<"This room is stored at: "<< &room <<endl;
roomsMap.insert(make_pair(rid, room));
} //end of BuildRoom
Sample Output (When the above function is called 3 times):
New Room Made: Room1
This room is stored at: 0x23fe5c
New Room Made: Room2
This room is stored at: 0x23fe5c
New Room Made: Room3
This room is stored at: 0x23fe5c
Does anyone know what I am doing wrong?
Thanks