// www.ug.it.usyd.edu.au/~elau8465/map.cc #include #include #include #include using namespace std; struct Employee { string name; Employee(const string& s) : name(s) { } }; bool operator<(const Employee& a, const Employee& b) { return a.name < b.name; } int main() { map id; // id[0] = Employee("John Smith"); id.insert(make_pair(0, Employee("John Smith"))); // id[1] = Employee("Mary Jane"); id.insert(make_pair(1, Employee("Mary Jane"))); // cout << id[0].name << endl; cout << id.find(0)->second.name << endl; map id2; Employee a("A"), b("B"); id2[a] = 100; id2[b] = 200; return 0; }