user1742419
user1742419

Reputation: 49

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. 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

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;
}

Upvotes: 0

Views: 1387

Answers (1)

Coding Mash
Coding Mash

Reputation: 3346

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.

Upvotes: 1

Related Questions