【发布时间】:2014-11-24 21:38:58
【问题描述】:
我环顾四周,看到了其中的不少,但没有一个为我的问题提供解决方案。我收到以下代码的编译错误:
错误:
代码:
const int TOP_WORDS = 25;
...
void topWords(Hash t, string word, string topA[]);
int main()
{
...
Hash table1;
string word = "example";
string topWordsArr[TOP_WORDS];
table1.addItem(word);
topWords(table1, word, topWordsArr);
...
}
...
void topWords(Hash t, string word, string topA[])
{
int i = 0;
int tempCount = t.itemCount(word);
int tempCount2 = t.itemCount(topA[i]);
while (tempCount > tempCount2 && i < TOP_WORDS) {
i++;
tempCount2 = t.itemCount(topA[i]);
}
if (i > 0)
我看到的有关此错误的所有其他帖子都涉及声明/传递字符串数组参数的语法不正确,但我已对其进行了两次和三次检查,并且确定它是正确的;虽然我之前错了..
【问题讨论】:
-
您遇到 what 编译错误?你只发布了一半。
-
我不敢相信。编译器清楚地说明了参数 1,而您所显示的关于参数 1 的所有内容都是
param1。根本不可能弄清楚未显示的内容有什么问题。 -
抱歉,我在写完之前不小心按了 Enter 键。现在修复它。
-
离完整的错误消息还很远。还有一两行包含详细信息,例如转换错误或其他内容。
-
@user3776749 至少会有更多的输出行(通常是
Note: ....)。包括他们。或者,你知道,也许可以发布一个sscce
标签: c++ arrays function function-parameter