Mega Code Archive
Categories
/
C++ Tutorial
/
Map Multimap
Declare a reverse iterator to a mapstring, itr
#include
#include
#include
using namespace std; int main() { map
m; m.insert(pair
("A", 100)); m.insert(pair
("G", 300)); m.insert(pair
("B", 200)); // Declare an iterator to a map
. map
::iterator itr; // Declare a reverse iterator to a map
. map
::reverse_iterator ritr; // show the contents of m in reverse order. cout << "The contents of m in reverse:\n"; for(ritr=m.rbegin(); ritr != m.rend(); ++ritr) cout << " " << ritr->first << ", " << ritr->second << endl; cout << endl; return 0; }