If i am about to loop through a map or a multimap normaly i use iterators, they are very easy and very handy! Altought everything works i do know there is a way to loop through things with the new c++11 format such as
for(auto a : multimap_name){}
My question is, what if the iterator is using a function? How can i make it work... herer is an example how i would do it with iterator:
for(multimap<intm, string>::iterator it = multimap_name.find(7); it != multimap_name.end(); it++){}
that code would run through the map find the number 7 key and from there it would loop untill the end of the map, how can i do the same with c++ Range-based for loops?
Ive tried a little bit and i dont get it to work, myh best guess was:
for(auto a.find(7) : multimap_name){}
I am new to programming and i am trying my best to not ask questions, but it just seems impossible not to sometimes. Thank you for your help!
Aucun commentaire:
Enregistrer un commentaire