繁体   English   中英

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

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM