我收到错误"变量类型不完整"无效,我找不到问题所在

I got the error 'variable has incomplete type 'void'', and I can't find what's wrong

本文关键字:无效 找不到 问题 错误 变量 类型      更新时间:2023-10-16

我必须计算向量的单词并将其放入计算单词的地图中。然后,函数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) {