我收到多个关于LNK2019的消息:未解析的外部符号
I am getting multiple messages referring to LNK2019: unresolved external symbol
我收到多个关于
的消息LNK2019:无法解析的外部符号"int_cdecl findlow (int,int)"
在function_main中被引用。每当我试图编译我的程序时,这些消息中就有4个弹出。我不知道如何解决这个问题,否则我就不会寻求帮助了。
#include <iostream>
using namespace std;
// This program calculates the average of the inputed temperatures and finds the highest and lowest
//
int main()
{
int numOfTemp;
int temp[50];
int pos;
double findAverage(int, int);
int findLowest(int, int);
int findHighest(int, int);
cout << "Please input the number of temperatures to be read (no more than 50)" << endl;
cin >> numOfTemp;
for (pos = 1; pos <= numOfTemp; pos++)
{
cout << "Input temperature " << pos << ":" << endl;
cin >> temp[pos];
}
cout << "The average temperature is " << findAverage(temp[pos], numOfTemp) << endl;
cout << "The lowest temperature is " << findLowest(temp[pos], numOfTemp) << endl;
cout << "The highest temperature is " << findHighest(temp[pos], numOfTemp) << endl;//calls function
}
double findAverage(int table[], int num)
{
for (int i = 0; i < num; i++)
{
int sum = 0;
sum += table[i];
return (sum / num); // calculates the average
}
}
int findLowest(int table[], int num)
{
float lowest;
lowest = table[0]; // make first element the lowest price
for (int count = 0; count < num; count++)
if (lowest > table[count])
lowest = table[count];
return lowest;
}
// This function returns the highest price in the array
int findHighest(int table[], int num)
{
float highest;
highest = table[0]; // make first element the highest price
for (int count = 0; count < num; count++)
if (highest < table[count])
highest = table[count];
return highest;
}
在c++中,函数需要在使用之前声明。您可以将findAverage
, findLowest
和findHighest
的函数体放在main
之上,或者使用前向声明。
EDIT:确保正确声明函数类型!就像我的评论说的,你声明并试图调用
double findAverage(int, int)
但只定义
double findAverage(int[], int)
将导致链接阶段失败,因为它找不到前者的定义
相关文章:
- boost::进程间消息队列引发错误
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 将无符号char*转换为std::istream*C++
- 在线编译器中的分段C++没有打印消息
- C++错误消息*成员参考.**初学者*
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- vscode g++链路故障:体系结构x86_64的未定义符号
- 在createdialog创建的窗口中捕获用于编辑控件的OnMouseMove消息
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 使用gcc从静态链接的文件中查找可选符号
- C++中无符号字符溢出
- 使用无符号字符数组有效存储内存
- 消息:: Simbolo使用未定义的类符号
- 包含类文件后的错误消息(多个定义的符号)
- 错误LNK2019:使用类编译程序时出现未解析的外部符号错误消息
- 我收到多个关于LNK2019的消息:未解析的外部符号
- 使用Win32 API列出存储在资源专用库(DLL)中的消息id和符号名称