// Different ways of assigning Map container contents // http://www.yolinux.com/TUTORIALS/CppStlMultiMap.html #include #include #include #include using namespace std; // Print a map template void mapPrint(map myMap, char *mapName){ typename map::iterator i; cout << "Entries of " << mapName << ":" << endl; for (i=myMap.begin(); i!=myMap.end(); i++) cout << "\t" << i->first << "==>" << i->second << endl; } int main(){ map employeeList; // 1) Assignment using array index notation employeeList["Mike C."] = 5234; employeeList["Charlie M."] = 3374; // 2) Assignment using member function insert() and STL pair employeeList.insert(pair("David D.", 1923)); // 3) Assignment using member function insert() and "value_type()" employeeList.insert(map::value_type("John A.", 7582)); // 4) Assignment using member function insert() and "make_pair()" employeeList.insert(make_pair("Peter Q.", 5328)); cout << "employeeList.size() = " << employeeList.size() << endl; mapPrint(employeeList, "employeeList"); }