I am getting errors that I have never seen before in a program that uses class englishweight with float number and float eng_weight to output number*englishweight and other things in the EW_driver.cpp. Here is what my build log looks like:

------ Build started: Project: assignment_2, Configuration: Debug Win32 ------1>Compiling...1>EW_Driver.cpp1>Linking...1>EW_Driver.obj : error LNK2019: unresolved external symbol "public: float __thiscall englishweight::getnumber(void)" (?getnumber@englishweight@@QAEMXZ) referenced in function _main1>EW_Driver.obj : error LNK2019: unresolved external symbol "public: float __thiscall englishweight::getweight(void)" (?getweight@englishweight@@QAEMXZ) referenced in function _main1>EW_Driver.obj : error LNK2019: unresolved external symbol "public: void __thiscall englishweight::def_weight(float)" (?def_weight@englishweight@@QAEXM@Z) referenced in function _main1>EW_Driver.obj : error LNK2019: unresolved external symbol "public: void __thiscall englishweight::def_number(float)" (?def_number@englishweight@@QAEXM@Z) referenced in function _main1>EW_Driver.obj : error LNK2019: unresolved external symbol "public: __thiscall englishweight::englishweight(void)" (??0englishweight@@QAE@XZ) referenced in function _main1>C:\Documents and Settings\Computer stuff man\Desktop\test progams\assignment_2\Debug\assignment_2.exe : fatal error LNK1120: 5 unresolved externals1>Build log was saved at "file://c:\Documents and Settings\Computer stuff man\Desktop\test progams\assignment_2\assignment_2\Debug\BuildLog.htm"1>assignment_2 - 6 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I don't know why these are popping up and I desperately need help. Here is my current source code:
Englishweight.h :

class englishweight{
private:float number;
float eng_weight; //not englishweight because IDE thinks it is constructor
float getnumber();
float getweight();
void def_number(float defn);
void def_weight(float defw);


class englishweight::englishweight()
class englishwieght::getnumber()
return number;
class englishweight::getweight()
return eng_weight;
class englishweight::def_number(float defn)
class englishweight::def_wieght(float defw)

$EW_driver.cpp :

using namespace std;
int main()
float defw=0; //define float eng_weight 
defn=0; //define number
float defo=0; //define ounces(part of defw seen later)
class englishweight testing;
cout<<"Welcome to Englishweight V 1.0!";
cout<<"Please input a weight-pounds then ounces."<<endl<<"Pounds: ";
cout<<endl<<"Ounces: ";
cout<<"Now enter a number."<<endl<<"number: ";
defw=(defw/16.0); //convert pounds to ounces
defw=(defw+defo); //add the converted weight to the ounces to get the final eng_weight
testing.def_number(defn); //use def_number and def_weight functions to define eng_weight 
cout<<endl<<"Englishweight + Englishweight is: "
<<( (testing.getweight() )*2);
cout<<endl<<"Englishweight - Englishweight is: "<<"0"; 
//will always be 0 so no need to use processing power
cout<<endl<<"Englishweight / Englishweight is: "<<"1";
 //will always be 1 so no need to use processing powercout<<endl<<"Englishweight * number is: "<<( (testing.getweight()) * (testing.getnumber()) );
cout<<endl<<"Number * Englishweight is: "<<( (testing.getnumber()) * (testing.getweight()) );
cout<<endl<<"Englishweight / number is: "<<( (testing.getweight()) / (testing.getnumber()) );
return 0;

Thank you for any help, it would be greatly appreciated as I am really trying to get this to work quickly.

The first thing you have to correct is the class englishwieght::getnumber() etc in your def.h file.

It should be a .cpp file and you need float englishweight::getnumber() etc. Not class. Note that by spelling it wieght and not as you spelt it in the first part of the program you avoided a name clash and the compiler accepted it.

(If you use g++ you get some very very serious warnings about this!).

This article has been dead for over six months. Start a new discussion instead.