[英]I got the error 'variable has incomplete type 'void'', and I can't find what's wrong
我必须计算向量的单词,然后将其放入包含单词的地图中。 然后,函数showFrequencies
必须显示/打印地图。
map<string, int>CountWords(vector<string> words) {
map<string, int> count;
for(auto i = words.begin(); i != words.end(); i++) {
count[*i]++;
}
return count;
}
void showFrequencies(CountWords(vector<string> name)) {
for (map<string, int>::const_iterator it = count.begin(); it !=
count.end(); ++it) {
cout << it->first << "\t" << it->second;}
}
int main(){
vector<string> words = {"hello", "you", "hello", "me", "chipolata", "you"};
showFrequencies(CountWords(words));
return 0;
}
void showFrequencies(CountWords(vector<string> name)) {
应该
void showFrequencies(const map<string, int>& name) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.