Cycle through a map in reverse.
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<char, int> mapObject;
int i;
for(i = 0; i <26; i++)
mapObject.insert(pair<char, int>('A' + i, 65 + i));
map<char, int>::reverse_iterator p;
for(p = mapObject.rbegin(); p != mapObject.rend(); p++) {
cout << p->first << " has ASCII value of ";
cout << p->second << endl;
}
return 0;
}
Related examples in the same category