Sorry. a trivial question on reference map access
if I have:
map<int,string> *items= new map<int,string>();
I do this?
string x = &items[100];
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So, first I ask; why are you dynamically allocating your map? It kind of defeats the purpose of using it in the first place. The map will internally use dynamic allocation for it’s items, but the map itself is cheap and you lose the ability to deterministically manage its memory via scope. So, your code becomes:
Otherwise you need to dereference the map pointer first.
Really though… don’t do that.