新手遇到map::insert中的问题
//cout number of times each world occurs in the input
map<string,int> word_count; //empty map from string to int
string word;
while(cin>>word){
//inserts element with key equal to world and value 1
//if word already in word_cout,insert does nothing
pair<map<string,int>::iterator,bool> ret=
word_cout.insert(make_pair(word,1));
if(!ret.second) //word already in word_cout
++ret.first->second; //increment couter
}
这是一个练习使用insert重写的单词程序,为什么最后的给counter加1不直接用++ret.second?