Assuming word_count is a map from string to size_t and word is a string, explain the following loop
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:11| Question number:21
All Answers
total answers (1)
The code just does the same thing as
`++word_count[word];`
. If the`word`
is in`map`
, then increase the count of that word by 1, else insert that word into`map`
, set the count to 0, and increase the count by 1.