我收到错误信息:“变量的类型不完整,类型为” void”,但我找不到问题所在

时间:2019-04-16 21:29:23

标签: c++

我不得不计算向量的单词,然后将其放在对单词进行计数的地图中。然后,功能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;
}

1 个答案:

答案 0 :(得分:2)

void showFrequencies(CountWords(vector<string> name)) {

应该是

void showFrequencies(const map<string, int>& name) {