Errors LNK2019 and LNK1120
Thank you for taking time to help me with my code.
I have two errors that I cannot figure out how to fix they are:
error LNK2019: unresolved external symbol "public: void __thiscall longClass::setNum(long)" (?setNum@longClass@@QAEXJ@Z) referenced in function "public: void __thiscall longClass::binToDec(long,class longClass)" (?binToDec@longClass@@QAEXJV1@@Z)
fatal error LNK1120: 1 unresolved externals
I made a header longClass.h but I do not use it but didn't change the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include <math.h>
#ifndef _longClass_h
#define _longClass_n
#include <iostream>
using namespace::std;
class longClass
{
public:
longClass();
longClass(long);
longClass(const longClass &);
void setNum(long);
long getNum();
void binToDec(long, longClass);
private:
long x;
};
#endif
longClass::longClass()
{
x=0;
}
longClass::longClass(const longClass & Object)
{
x=Object.x;
}
long longClass::getNum()
{
return x;
}
void longClass::binToDec(long binaryNumber, longClass weight)
{
long bit;
if (binaryNumber > 0)
{
bit = binaryNumber % 10;
setNum(getNum() bit * (int)(pow(2.0, weight.getNum())));
binaryNumber = binaryNumber / 10;
weight.setNum(weight.getNum() 1);
binToDec(binaryNumber, weight);
}
}
int main() {
long binaryNum;
longClass bitWeight;
longClass decimalNum;
do {
cout << "Enter the number in binary: ";
cin >> binaryNum;
cout << "n";
if (binaryNum >= 0) {
decimalNum.binToDec(binaryNum, bitWeight);
cout << "Binary " << binaryNum << " = " << decimalNum.getNum() << " decimaln";
}
decimalNum.setNum(0);
} while(binaryNum>=0);
system("pause");
return 0;
}
|
Last edited on
No method setNum was defined. Please use [ code ] [ /code ] tags when posting source code.
Thanks for the help filipe forgot this
1 2 3 4
|
void longClass::setNum(long amount)
{
x = amount;
}
|
and also sorry about forgetting to use the [ code ] [ /code ] tags
Topic archived. No new replies allowed.