We help IT Professionals succeed at work.

std::MAP for a string and object pointer

tommym121
tommym121 asked
on
511 Views
Last Modified: 2013-12-07
map<string, Object*> objectMap;

Object *pObject1;
Object *pObject2;

pObjet1 = new Object();

objectMap["Object1"] = pObject1;

pObject2 = objectMap["Object1"] ;

For some reason the pObject1 and pObject2 not point to the same object? Why that happen? How can I assign the pObject1 address into the objectMap["Object1"] so objectMap["Object1"] will return the same address (i.e. pObject1) rather a different address (pObject2)
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.