#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
map<string, int> m;
m.insert(pair<string, int>("A", 100));
m.insert(pair<string, int>("G", 300));
m.insert(pair<string, int>("B", 200));
// Declare an iterator to a map<string, int>.
map<string, int>::iterator itr;
// Display the last element in m.
itr = m.end();
--itr;
cout << "Here is the last key/value pair in m: "
<< itr->first << ", " << itr->second << "\n\n";
return 0;
}
|