Mega Code Archive
Categories
/
C++ Tutorial
/
Map Multimap
Display the last element in map
#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; // 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; }