I have one map and queue with following format.
I stored Object pointers ( say MyCommand*) in both of the map and queue.
But after I poped one object from queue the same object in the map is also shown as null.
(Initially I stored same elements in both data structures)
map <string, MyCommand*> mapTest;
queue<MyCommand*> myQ;
Initially.....
Map has-> cmd1 cmd2 cmd3 cmd4
Q has -> cmd1 cmd2 cmd3 cmd4
I poped cmd2 (This is a pointer)
Then in
Map -> cmd1 (null) cmd3 cmd4
Q has -> cmd1 cmd3 cmd4
Could u please help me to sort out this problem.
And I didn't do any thing with Map at all.....>??????????????????
| QUOTE (kasun04 @ Jan 26 2007, 08:38 AM) |
| And I didn't do any thing with Map at all.....>?????????????????? |
I think you are having some problem with terminology.
"POP" tends to mean you pull somthing of the top of a container and everything else in the container moves up one position (closer to the top). But then again it is a very inpricise term. So please be a bit more specific in your terminology.
Well its hard to understand what the problem is without looking at the code.
Please post the code where you insert and "pop".
Thanks myork...
I fixed the problem.
It was due to a deletion of a pointer.
More precisely... I poped a pointer to the object and use the object and delete the pointer. So, the real object is deallocated.... Thats the prob...