Question about 'map'

Started by
1 comment, last by Juliean 13 years, 9 months ago
Hi there,

I've got a (hopefully) simple question, what is the best way to go through all elements of that map:

map<int, CClass>

without knowing all the 'ints'?

What I was trying to do was:

// is filled with infos from another mapmap<int, CClass> TempMap;int Size = TempMap.size();for(int i = 0; i < Size; i++){    CClass Temp = TempMap.begin();    TempMap.erase(TempMap.begin());        //do something with 'Temp'}


My problem is just that begin() returns an iterator and I don't have any idea how to work with this. Can anyone pls help me? Or does anyone got even an better idea going through that map?
Advertisement
for (map<int, CClass>::iterator it = TempMap.begin(), end = TempMap.end();     it != end; ++it) {  int key = it->first;  CClass value = it->second;  //...}


Does that answer your question?
Yes, it does, works that way, thanks a lot!

This topic is closed to new replies.

Advertisement