编译错误,未解决的外部错误
Compiling error, unresolved external error
我尝试编写一个程序来删除5个输入中的最低输入并计算其余4个输入的平均值,但由于收到错误,我无法编译。错误是:
错误1错误LNK2019:无法解析的外部符号"int __cdecl findlow (int &,int &,int &,int &,int &)"(?findLowest@@YAHAAH0000@Z)在函数"void __cdecl calaverage (double &)"中引用(? calcAverage@@YAXAAN@Z)
我不知道这是什么意思,也不知道如何解决它。我的代码如下:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void getScore(int &, int &, int &, int &,int &);
void calcAverage(double &);
int findLowest(int &, int &, int &, int &, int &);
int main()
{
int test1 = 0, test2 = 0, test3 = 0, test4 = 0, test5 = 0;
string response;
//double averge;
getScore(test1, test2, test3, test4, test5);
//calcAverage(averge);
cout << "Are there any more test scores?" << endl;
cin >> response;
cout << endl;
if (response == "yes")
{
//getScore(test1, test2, test3, test4, test5);
//calcAverage(averge);
}
system("pause");
return 0;
}
void getScore(int &num1, int &num2, int &num3, int &num4, int &num5)
{
cout << "What was your score for the first test?" << endl;
cin >> num1;
cout << endl;
if (num1 < 1 || num1 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the second test?" << endl;
cin >> num2;
cout << endl;
if(num2 < 1 || num2 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the third test?" << endl;
cin >> num3;
cout << endl;
if(num3 < 1 || num3 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the fourth test?" << endl;
cin >> num4;
cout << endl;
if(num4 < 1 || num4 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the fifth test?" << endl;
cin >> num5;
cout << endl;
if(num5 < 1 || num5 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
//return num1, num2, num3, num4, num5;
}
void calcAverage(double &average)
{
int number1, number2, number3, number4, number5, lowest;
lowest = findLowest(number1, number2, number3, number4, number5);
cout << lowest << endl;
}
int findLowest(int &num1, int &num2, int &num3, int &num4, int &num5, int &lowest)
{
lowest = num1;
if (num2 < lowest)
{
lowest = num2;
//return lowest;
}
else if (num3 < lowest)
{
lowest = num3;
//return lowest;
}
else if (num4 < lowest)
{
lowest = num4;
//return lowest;
}
else if (num5 < lowest)
{
lowest = num5;
//return lowest;
}
return lowest;
}
什么可能导致错误,我该如何修复它?
问题是:
int findLowest(int &, int &, int &, int &, int &);
vs。:
int findLowest(int &num1, int &num2, int &num3, int &num4, int &num5, int &lowest)
在定义中比声明中多一个参数。在我看来,lowest
应该只是一个局部变量,而不是一个参数。
相关文章:
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- Visual Studio 2017 中的 QtMetaObject 未解决的外部错误
- 外部"C"拆卸导致奇怪的链接器错误
- C++指针无法在函数外部传递值和分段错误(核心转储)错误
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 外部函数在 main() 上调用时返回分段错误 11.(C++)
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- 每次我要使用外部资源时,我都会得到:collect2。exe:错误 ld 返回 1 退出状态
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- C#WPF和C++/CLI以及C++在C++/CLI中添加外部库错误
- 函数 LNK2019 "int __cdecl __scrt_common_main_seh(void)" 中引用的未解析外部符号主错误 (?__scrt_common_main_seh@@YAHXZ
- C++:在"try"外部创建的类型会导致错误,但在内部不会
- 编译错误外部接口Simulink
- 为什么这会给出多个定义错误:外部 int i;国际 i;.