displaying a map

map<string,int>::iterator itr;
for(itr=phone.begin();itr!=phone.end();itr++)
{
cout<<"the name is" <<itr->first<<",";
cout<<"the phone number is"<<*(itr).second<<endl;
}


i am getting this error for the above code:
struct std::_Rb_tree_iterator<std::pair<const std::string, int> >' has no member named 'second'


for the second statement in the for loop.


please help.....
You need to put the dereference operator on the inside of your brackets:

 
... (*itr).second ...
@ajh32

Thanks ya...its working..
Topic archived. No new replies allowed.