// MORE details on this example to come // update - see the text or other resources for more details on list and other // similar STL classes #include #include #include #include using std::map; using std::list; using std::cout; using std::endl; typedef std::string Word; int main() { Word w1 = "Hello", w2 = "Cat", w3 = "UMCP", w4 = "space"; map< Word, list > m; // declare the map list l1; m.insert( make_pair( w4, l1 ) ); m.insert( make_pair( w1, list() ) ); m[ w1 ].push_back( 5 ); m[ w1 ].push_back( 18 ); m[ w1 ].push_back( -5 ); cout << m[ w4 ].size() << endl; cout << m[ "Hello" ].size() << endl; cout << m[ "hello" ].size() << endl; cout << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*" << endl; list::const_iterator i; i = m[ w1 ].begin(); for ( ; i != m[ w1 ].end(); i++ ) cout << *i << endl; return 0; }