Exercise 11.9
1#include <iostream>2#include <string>3#include <iostream>4#include <vector>5#include <algorithm>6#include <list>7#include <functional>8#include <iterator>9#include <map>Ten#include <Set> One using namespacestd; A using namespaceplaceholders; - - intMain () the { - stringstr; - intnum; -map<string, list<int>>words; + while(Cin >> STR >>num) - { + words[str].push_back (num); A } at for(auto c:words) - { -cout << C.first <<" "; - for(auto A:c.second) -cout << a <<" "; -cout <<Endl; in } -System"Pause"); to return 0; +}
Exercise 11.10
You can define a map vector<int>::iterator to int, and you cannot define a map list<int>::iterator to int. Because of the keyword type requirements < operations of the map, the list iterator does not support comparison operations. Vectors are sequentially accessed.
Exercise 11.11
1 multiset<sales_data,bool (*) COMPAREISBN (const sales_data &,const Sales _data &) > Bookstore (COMPAREISBN);
Note that this is a pointer to the function
C++primer 11.2.2 sessions