linking errors LNK2001
-
When I build my bank.cpp file, I get these linking errors. I don't understand these coding errors, I would appreciate any help you could give me. Linking... Bank.obj : error LNK2001: unresolved external symbol "public: class Account & __thiscall Customer::getchecking(void)" (?getchecking@Customer@@QAEAAVAccount@@XZ) Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Account::setbalance(float)" (?setbalance@Account@@QAEXM@Z) Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Account::setnum(int)" (?setnum@Account@@QAEXH@Z) Bank.obj : error LNK2001: unresolved external symbol "public: class Account & __thiscall Customer::getsavings(void)" (?getsavings@Customer@@QAEAAVAccount@@XZ) Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Customer::setpin(int)" (?setpin@Customer@@QAEXH@Z) Bank.obj : error LNK2001: unresolved external symbol "public: __thiscall Customer::Customer(void)" (??0Customer@@QAE@XZ) Bank.obj : error LNK2001: unresolved external symbol "public: float __thiscall Account::getbalance(void)" (?getbalance@Account@@QAEMXZ) Bank.obj : error LNK2001: unresolved external symbol "public: int __thiscall Account::getnum(void)" (?getnum@Account@@QAEHXZ) Bank.obj : error LNK2001: unresolved external symbol "public: int __thiscall Customer::getpin(void)" (?getpin@Customer@@QAEHXZ) LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Bank.exe : fatal error LNK1120: 10 unresolved externals Error executing link.exe. Bank.exe - 11 error(s), 0 warning(s) This is my bank.cpp file............................. #include "Bank.h" #include Bank::Bank() { numcustomers=0; companyname=""; } int Bank::getNumcustomers() {return numcustomers;} char * Bank::getCompanyname() {return companyname;} Customer& Bank::getCustomer(int index) { return customers[index];} void Bank::setNumcustomers(int n) { numcustomers=n; } void Bank::setCompanyname(char * c) { companyname =c;} void Bank::setCustomer(Customer &c,int index) {customers[index]= c;} bool Bank::readCustomers() { ifstream infile; infile.open("customers.dat"); if(!infile) { return false; } else { infile>>numcustomers; int numberpin=0; int cksavnumber=0; float savckbalance=0.00f; customers = new Customer[numcustomers]; for(int x1=0;x1<=numcustomers;x1++) { infile>>numberpin; infile>>cksavnumber; infile>>savckbalance; customers [x1]
-
When I build my bank.cpp file, I get these linking errors. I don't understand these coding errors, I would appreciate any help you could give me. Linking... Bank.obj : error LNK2001: unresolved external symbol "public: class Account & __thiscall Customer::getchecking(void)" (?getchecking@Customer@@QAEAAVAccount@@XZ) Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Account::setbalance(float)" (?setbalance@Account@@QAEXM@Z) Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Account::setnum(int)" (?setnum@Account@@QAEXH@Z) Bank.obj : error LNK2001: unresolved external symbol "public: class Account & __thiscall Customer::getsavings(void)" (?getsavings@Customer@@QAEAAVAccount@@XZ) Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Customer::setpin(int)" (?setpin@Customer@@QAEXH@Z) Bank.obj : error LNK2001: unresolved external symbol "public: __thiscall Customer::Customer(void)" (??0Customer@@QAE@XZ) Bank.obj : error LNK2001: unresolved external symbol "public: float __thiscall Account::getbalance(void)" (?getbalance@Account@@QAEMXZ) Bank.obj : error LNK2001: unresolved external symbol "public: int __thiscall Account::getnum(void)" (?getnum@Account@@QAEHXZ) Bank.obj : error LNK2001: unresolved external symbol "public: int __thiscall Customer::getpin(void)" (?getpin@Customer@@QAEHXZ) LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Bank.exe : fatal error LNK1120: 10 unresolved externals Error executing link.exe. Bank.exe - 11 error(s), 0 warning(s) This is my bank.cpp file............................. #include "Bank.h" #include Bank::Bank() { numcustomers=0; companyname=""; } int Bank::getNumcustomers() {return numcustomers;} char * Bank::getCompanyname() {return companyname;} Customer& Bank::getCustomer(int index) { return customers[index];} void Bank::setNumcustomers(int n) { numcustomers=n; } void Bank::setCompanyname(char * c) { companyname =c;} void Bank::setCustomer(Customer &c,int index) {customers[index]= c;} bool Bank::readCustomers() { ifstream infile; infile.open("customers.dat"); if(!infile) { return false; } else { infile>>numcustomers; int numberpin=0; int cksavnumber=0; float savckbalance=0.00f; customers = new Customer[numcustomers]; for(int x1=0;x1<=numcustomers;x1++) { infile>>numberpin; infile>>cksavnumber; infile>>savckbalance; customers [x1]
The error means that the compiler can see that you've declared your intention to define a function, but cannot see the function definition. Your second include got lost, but if it's stdafx.h, anything before stdafx.h is lost, you need to include it first. Otherwise I'm not sure off the top of my head, but that is what the error means. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002 Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002