August 2012
Intermediate to advanced
976 pages
30h 17m
English
As we’ve just seen, when we define a map, we must indicate both the key and value type; when we define a set, we specify only a key type, because there is no value type. Each of the associative containers defines a default constructor, which creates an empty container of the specified type. We can also initialize an associative container as a copy of another container of the same type or from a range of values, so long as those values can be converted to the type of the container. Under the new standard, we can also list initialize the elements:
map<string, size_t> word_count; // empty// list initialization ...
Read now
Unlock full access