我收到错误"变量类型不完整"无效,我找不到问题所在
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) {
相关文章:
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 为什么野牛仍在使用"int yylex(void)",却找不到"int yylex(YYS
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 奇怪的(对我来说)返回声明 - 在谷歌上找不到任何关于它的信息
- 找不到QtResource文件中的文件
- VC++本机单元测试,找不到调试符号
- RegGetValue在当前用户下找不到名称
- 带有 -stdlib=libc++ 的 clang++ 9.0.1 找不到<optional>
- c++找不到具有相同哈希的无序集合元素
- 找不到以下加速库:boost_fiber
- 找不到 FLTK(缺少:FLTK_INCLUDE_DIR)
- 设置 Visual Studio for MPI: 找不到标识符错误
- "assimp/config.h"找不到,但它在文件夹中
- 链接器找不到在虚拟类 c++ 中访问的静态字段的符号
- C++系统找不到指定的文件错误
- 我收到错误"变量类型不完整"无效,我找不到问题所在
- 错误:控制到达非无效功能的末尾.找不到修复错误的位置
- 瓦尔格林德找不到无效的写入
- 找不到错误 读取大小 4 瓦尔格林德无效