Advertisement Jump to content
Sign in to follow this  

Question about 'map'

This topic is 3109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 map
map<int, CClass> TempMap;

int Size = TempMap.size();

for(int i = 0; i < Size; i++)
CClass Temp = 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?

Share this post

Link to post
Share on other sites

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?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!