Z
zhangyefei.yefei
can someone tell me ,is the following about end() right ? the
printed result seems ok,but i am not sure if i can use end() such
way.
thanks.
#include <iostream>
#include <map>
using namespace std;
int main ()
{
map<char,int> mymap;
map<char,int>::iterator it;
mymap['a']=20;
mymap['b']=40;
mymap['c']=60;
mymap['d']=80;
mymap['e']=100;
it=mymap.lower_bound ('b'); // it points to b
for ( ; it != mymap.end(); it--)
cout << (*it).first << " => " << (*it).second << endl;
return 0;
}
the output is:
b => 40
a => 20
printed result seems ok,but i am not sure if i can use end() such
way.
thanks.
#include <iostream>
#include <map>
using namespace std;
int main ()
{
map<char,int> mymap;
map<char,int>::iterator it;
mymap['a']=20;
mymap['b']=40;
mymap['c']=60;
mymap['d']=80;
mymap['e']=100;
it=mymap.lower_bound ('b'); // it points to b
for ( ; it != mymap.end(); it--)
cout << (*it).first << " => " << (*it).second << endl;
return 0;
}
the output is:
b => 40
a => 20