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??
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??