c++ - Compiler Error 2019 Unresolved External Symbol -
this question has answer here:
i trying compile program make sure code working. getting error 2019 unresolved external following messages:
1>------ build started: project: week 2 dating service, configuration: debug win32 ------ 1> client.cpp 1>client.obj : error lnk2019: unresolved external symbol "private: void __thiscall client::checkname(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?checkname@client@@aaexaav?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@@z) referenced in function "public: __thiscall client::client(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0client@@qae@v?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@@z) 1>client.obj : error lnk2019: unresolved external symbol "private: void __thiscall client::checksex(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?checksex@client@@aaexaav?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@@z) referenced in function "public: __thiscall client::client(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0client@@qae@v?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@0@z) 1>client.obj : error lnk2019: unresolved external symbol "private: void __thiscall client::checkphone(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?checkphone@client@@aaexaav?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@@z) referenced in function "public: __thiscall client::client(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0client@@qae@v?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@00@z) 1>c:\users\owner\documents\visual studio 2010\projects\ciss 350\week 2 dating service\debug\week 2 dating service.exe : fatal error lnk1120: 3 unresolved externals
here of code...
header: //specification file client.h class. class hold member data , provide necessary functions access data.
#ifndef client_h #define client_h #include <iostream> #include <vector> using namespace std; class client { private: //member variables string name; //hold clients name string sex; //single char hold sex string phone; //holds 7 digit phone number vector<string> interests; //private member functions void interest(vector<string>); void checkname(string &); void checksex(string &); void checkphone(string &); public: //public variables bool hasmatch; string match; //constructors client(); client(string); client(string, string); client(string, string, string); client(string, string, string, vector<string>); //mutators void setname(string); void setsex(string); void setphone(string); void setinterests(vector<string>); void setclient(string, string, string, vector<string>); //accessors void getname(string &); void getsex(string &); void getphone(string &); void getinterests(vector<string> &); void getclient(string &, string &, string &, vector<string> &); }; #endif
implementation file:
//implementation file client.h class. #include <iostream> #include <string> #include <vector> #include "client.h" using namespace std; //private member functions void client::interest(vector<string> inter) { int vecsize = inter.size(); for(int = 0; < vecsize; i++) { interests[i] = inter[i]; } } void checkname(string &nm) { { cout << "name longer 20 characters. please enter new name:"; cin >> nm; } while(nm.size() > 20); } void checksex(string &sx) { int size = sx.size(); if(size > 1) { sx = sx[0]; } { if(sx != "m" || sx != "m" || sx != "f" || sx != "f") { cout << "please enter sex(m or f):"; cin >> sx; } } while(sx != "m" || sx != "m" || sx != "f" || sx != "f"); } void checkphone(string &ph) { int size = ph.size(); bool isgood= true; if(size > 8) isgood = false; for(int = 0; < size; i++) { if(static_cast<int>(ph[i]) != 32 && ph[i] > '9'|| ph[i] < '0') { isgood = false; } } if(isgood == false) { cout << "phone number not valid.\n" << "please enter new number:"; cin >>ph; checkphone(ph); } } //contructors client::client() { name = " "; phone = " "; sex = " "; interests[0] = " "; hasmatch = false; match = " "; } client::client(string nm) { checkname(nm); name = nm; phone = " "; sex = " "; interests[0] = " "; hasmatch = false; match = " "; } client::client(string nm, string sx) { checkname(nm); name = nm; phone = " "; checksex(sx); sex = sx; interests[0] = " "; hasmatch = false; match = " "; } client::client(string nm, string sx, string ph) { checkname(nm); name = nm; checkphone(ph); phone = ph; checksex(sx); sex = sx; interests[0] = " "; hasmatch = false; match = " "; } client::client(string nm, string sx, string ph, vector<string> inter) { checkname(nm); name = nm; checkphone(ph); phone = ph; checksex(sx); sex = sx; interest(inter); hasmatch = false; match = " "; } //mutators void client::setname(string nm) { checkname(nm); name = nm; } void client::setsex(string sx) { checksex(sx); sex = sx; } void client::setphone(string ph) { checkphone(ph); phone = ph; } void client::setinterests(vector<string> inter) { interest(inter); } void client::setclient(string nm, string sx, string ph, vector<string> inter) { checkname(nm); name = nm; checkphone(ph); phone = ph; checksex(sx); sex = sx; interest(inter); } //accessors void client::getname(string &nm) { nm = name; } void client::getsex(string &sx) { sx = sex; } void client::getphone(string &ph) { ph = phone; } void client::getinterests(vector<string> &inter) { inter = interests; } void client::getclient(string &nm, string &sx, string &ph, vector<string> &inter) { nm = name; sx = sex; ph = phone; inter = interests; }
main file:
#include <iostream> #include <string> #include <vector> #include <iomanip> #include <list> #include "client.h" using namespace std; //global variables //function prototypes char mainmenu(); void addmenu(); void printmenu(); bool initload(); void closeprogram(); int main() { list<client> males; list<client> females; client mclient; client fclient; char choice; { choice = mainmenu(); switch(choice) //switch to call either user selection { case ('1'): { addmenu(); break; } case ('2'): { printmenu(); break; } case ('3'): { closeprogram(); } } } while(choice <= '3' || choice >= '1' || isalpha(choice)); //input validation ensure user selects acceptable value } char mainmenu() { char choice; //for main menu choice cout << endl; { cout << "main menu\n" << "1. client menu\n" << "2. print menu\n" << "3. exit\n"; cout << "selection: "; cin >> choice; cout << endl; } while(choice < '1' || choice > '3' || isalpha(choice)); //input validation ensure user selects acceptable value return choice; } void addmenu() { char choice; //for main menu choice cout << endl; { cout << "client menu\n" << "1. add client\n" << "2. unmatch client\n" << "3. match client\n" << "4. return\n"; cout << "selection: "; cin >> choice; cout << endl; } while(choice < '1' || choice > '4' || isalpha(choice)); //input validation ensure user selects acceptable value } void printmenu() { char choice; //for main menu choice cout << endl; { cout << "print menu\n" << "1. print matched clients\n" << "2. print free clients\n" << "3. print clients\n" << "4. return\n"; cout << "selection: "; cin >> choice; cout << endl; } while(choice < '1' || choice > '4' || isalpha(choice)); //input validation ensure user selects acceptable value } bool initload() { return true; } void closeprogram() { }
you haven't qualified many of function definitions. example:
void checkname(string &nm)
this should be:
void client::checkname(string &nm)
because member of client
class. same true checksex
, checkphone
.
Comments
Post a Comment