what is going on?

W

wenmang

Header{
char key[10];
};

struct Mydata
{
char data[10];
};


struct wholeData
{
Header key;
Mydata data;
};


map <string, wholeData *, less<string> > myMap;


when I do:
.....insert some of wholeData...

map <string, wholeData *, less<string> > ::iterator itr;
for(itr=myMap.begin(); itr != myMap.end(); ++ itr)
{
//cout << "key: " << itr->first << " header: " << itr->second->header
<< endl; //not works, no ouput for header content
cout << "key: " << itr->second->header.key << itr->second->header <<
endl; //works now, why???
}

It seems to me that calling itr->first seems "invalidate" itr and next
call to itr->second which will point to other place??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top