简体   繁体   English

错误:无法解析的外部符号

[英]Error: Unresolved external symbol

I'm supposed to write a program that reads in a length in feet and inches and outputs the equivalent length in meters and centimeters. 我应该编写一个程序,该程序以英尺和英寸为单位读取长度,并以米和厘米为单位输出等效长度。 Use at least three functions: one for input, one or more for calculating, and one for output. 至少使用三个功能:一个用于输入,一个或多个用于计算,以及一个用于输出。 Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. 包括一个循环,使用户可以对新的输入值重复此计算,直到用户说自己想结束程序为止。 Google for conversion between different units. Google用于不同单位之间的转换。 The thing is I'm supposed to use call by reference functions. 问题是我应该使用引用函数调用。 So, I've tried it, but I keep getting this error: 因此,我已经尝试过了,但是仍然出现此错误:

error LNK2019: unresolved external symbol "double __cdecl convert(double,double)" (?convert@@YANNN@Z) referenced in function _main 错误LNK2019:函数_main中引用的未解析的外部符号“ double __cdecl convert(double,double)”(?convert @@ YANNN @ Z)

I've never had this error before so I don't even get what it's telling me. 我以前从未遇到过此错误,所以我什至不明白它在告诉我什么。 I'm going to put the loop in after I solve this problem because I know how to do that already. 解决此问题后,我将放入循环,因为我已经知道该怎么做。 Thank you. 谢谢。

#include <iostream>
#include <conio.h>

using namespace std;

int bLength, sLength;

void  length(double bLength, double sLength);
double  conv(double bLength, double sLength);
void  output(double bLength, double sLength);


int main()
{
length(bLength, sLength);
conv(bLength, sLength);
output(bLength, sLength);

getche();
return 0;
}

void length(double bLength, double sLength)
{
            cout<<"Enter a length in feet, then enter a length in inches if needed: ";
        cin>>bLength>>sLength;
    return;
}

double conv(double bLength, double sLength)
{
    bLength = bLength * 2.54;
    sLength = sLength * .3048;

    return bLength;
    return sLength;
}

        void output(double bLength, double sLength)
        {
            cout<<"Your input is converted to "<<bLength<<" meters, and "<<sLength<<"                 centimeters.";
    return;
}

Your function definition and declaration do not match. 您的函数定义和声明不匹配。

double  convert(double bLength, double sLength);

And you implement it thus. 然后您实现了它。

double conv(double bLength, double sLength)
{
  //code runs here
}

Note the difference in function name. 注意函数名称的不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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