1: //map01.cpp 3: #include <iostream> 4: #include <map> 5: using namespace std; 7: int main() 8: { 9: cout << "\nThis program creates an empty map, places three " 10: "key/value pairs into it,\nthen displays the values by " 11: "accessing them via their keys."; 12: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 14: map<char, int> m; 15: if (m.empty()) 16: cout << "\nThe newly created map is currently empty."; 17: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 19: m['A'] = 65; 20: m['B'] = 66; 21: m['C'] = 67; 22: cout << "\nAfter entering the three key/value pairs, the size of " 23: "the map is now " << m.size() << "."; 24: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 26: cout << "\nIf the component key is A, the component value is " 27: << m['A'] << "."; 28: cout << "\nIf the component key is B, the component value is " 29: << m['B'] << "."; 30: cout << "\nIf the component key is C, the component value is " 31: << m['C'] << "."; 32: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 33: }