944,061 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 29369
  • C++ RSS
Mar 2nd, 2005
0

error LNK2001: unresolved external symbol

Expand Post »
i keep getting error messages when i try to build my program:

EmpType.obj : error LNK2001: unresolved external symbol "public: __thiscall SortedType:ortedType(void)" (??0SortedType@@QAE@XZ)

EmpType.obj : error LNK2001: unresolved external symbol "public: void __thiscall SortedType::ResetList(void)" (?ResetList@SortedType@@QAEXXZ)

I also get the same error for InsertItem,GetNextItem,DeleteItem,RetrieveItem,LengthIs

any help in understanding this would be a great help
here is my code:

//EmpType.cpp
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4. #include "SortedType.h"
  5. #include "ItemType.h"
  6.  
  7. ofstream outData;
  8. enum CommandType {JOIN,QUIT,CHANGE,PROMOTE,DEMOTE,
  9. PAYDAY,EMPLOYEES,UNEMPLOYED,DUMP,END};
  10. void Join(SortedType&,SortedType&);
  11. void GetCommand(CommandType&);
  12. void Quit(SortedType&,SortedType&);
  13. void Change(SortedType&);
  14. void Unemployed(SortedType&);
  15. void Dump(SortedType&,SortedType&);
  16. void Employees(SortedType&);
  17. void Payday(SortedType&,SortedType&);
  18. void Demote(SortedType&);
  19. void Promote(SortedType&);
  20.  
  21. void main()
  22. {
  23. using namespace std;
  24. cout<<"Welcome to the Employee Program"<<endl;
  25. CommandType command;
  26. SortedType ourList,list2;
  27.  
  28. outData.open("data.dat");
  29. GetCommand(command);
  30. while(command != END)
  31. {
  32. switch(command)
  33. {
  34. case JOIN: Join(ourList,list2);break;
  35. case QUIT: Quit(ourList,list2);break;
  36. case CHANGE: Change(ourList);break;
  37. case PROMOTE: Promote(ourList);break;
  38. case DEMOTE: Demote(ourList);break;
  39. case PAYDAY: Payday(ourList,list2);break;
  40. case EMPLOYEES: Employees(ourList);break;
  41. case UNEMPLOYED: Unemployed(list2);break;
  42. case DUMP: Dump(ourList,list2);break;
  43. }
  44. GetCommand(command);
  45. }
  46.  
  47. }
  48.  
  49. void GetCommand(CommandType& command)
  50. {
  51.  
  52. cout<<"EMPLOYEE MENU PROGRAM"<<endl;
  53. outData<<"EMPLOYEE MENU PROGRAM"<<endl;
  54. cout<<"Type in a Capitial letter from the choices below then press ENTER"<<endl;
  55. outData<<"Type in a Capitial letter from the choices below then press ENTER"<<endl;
  56. cout<<endl;
  57. outData<<endl;
  58. cout<<" J: A person joins a new company."<<endl;
  59. outData<<" J: A person joins a new company."<<endl;
  60. cout<<" Q: A person quits a company."<<endl;
  61. outData<<" Q: A person quits a company."<<endl;
  62. cout<<" C: A person quits their job and joins a different company."<<endl;
  63. outData<<" C: A person quits their job and joins a different company."<<endl;
  64. cout<<" P: A person is promoted."<<endl;
  65. outData<<" P: A person is promoted."<<endl;
  66. cout<<" D: A person is demoted."<<endl;
  67. outData<<" D: A person is demoted."<<endl;
  68. cout<<" M: payday."<<endl;
  69. outData<<" M: payday."<<endl;
  70. cout<<" E: Print list of employees in a company."<<endl;
  71. outData<<" E: Print list of employees in a company."<<endl;
  72. cout<<" U: Print list of unemployeed people."<<endl;
  73. outData<<" U: Print list of unemployeed people."<<endl;
  74. cout<<" A: Print both employee and unemployeed list."<<endl;
  75. outData<<" A: Print both employee and unemployeed list."<<endl;
  76. cout<<" X: END OF PROGRAM"<<endl;
  77. outData<<" X: END OF PROGRAM"<<endl;
  78. char letter;
  79. cin>>letter;
  80. cout<<endl;
  81.  
  82. bool okay = false;
  83. while(!okay)
  84. {
  85. okay = true;
  86. switch(letter)
  87. {
  88.  
  89. case 'J': command = JOIN; break;
  90. case 'Q': command = QUIT; break;
  91. case 'C': command = CHANGE; break;
  92. case 'P': command = PROMOTE;break;
  93. case 'D': command = DEMOTE;break;
  94. case 'M': command = PAYDAY; break;
  95. case 'E': command = EMPLOYEES; break;
  96. case 'U': command = UNEMPLOYED; break;
  97. case 'A': command = DUMP;break;
  98. case 'X': command = END;break;
  99. default: cout<<"Letter Entered was not one"
  100. <<" of the choices above. ENTER"
  101. <<" another Letter then press return: "<<endl;
  102. outData<<"Letter Entered was not one"
  103. <<" of the choices above. ENTER"
  104. <<" another Letter then press return: "<<endl;
  105. cin>>letter;
  106. okay = false;
  107. }
  108. }
  109. }
  110.  
  111. void Join(SortedType& ourList,SortedType& list2)
  112. {
  113. bool check;
  114. string name,company;
  115. cout<<"Enter the employee's name"<<endl;
  116. outData<<"Enter the employee's name"<<endl;
  117. cin>>name;
  118. cout<<"Enter the company"<<endl;
  119. outData<<"Enter the company"<<endl;
  120. cin >> company;
  121.  
  122. ItemType obj(name,company);
  123. int length = ourList.LengthIs();
  124.  
  125. list2.RetrieveItem(obj,check);
  126. if(check)
  127. list2.DeleteItem(obj);
  128.  
  129. for(int count = 0;count < length;count++)
  130. {
  131. ourList.GetNextItem(obj);
  132. ourList.DeleteItem(obj);
  133. obj.PromoteMe();
  134. ourList.InsertItem(obj);
  135. }
  136.  
  137. ourList.InsertItem(obj);
  138. ourList.ResetList();
  139. }
  140.  
  141. void Quit(SortedType& list2,SortedType& ourList)
  142. {
  143.  
  144. cout<<"QUIT"<<endl;
  145. string name,company;
  146. cout<<"Enter the employee's name"<<endl;
  147. outData<<"Enter the employee's name"<<endl;
  148. cin>>name;
  149. cout<<"Enter the company"<<endl;
  150. outData<<"Enter the company"<<endl;
  151. cin >> company;
  152.  
  153. ItemType obj(name,company);
  154. int length = ourList.LengthIs();
  155. ourList.DeleteItem(obj);
  156. list2.InsertItem(obj);
  157.  
  158.  
  159. for(int count = 0;count < length;count++)
  160. {
  161. ourList.GetNextItem(obj);
  162. obj.DemoteMe();
  163. ourList.InsertItem(obj);
  164. }
  165. }
  166.  
  167. void Change(SortedType& ourList)
  168. {
  169. cout<<"CHANGE"<<endl;
  170. bool check = false;
  171. string name,company;
  172. while(!check)
  173. {
  174. check = true;
  175.  
  176. cout<<"Enter the employee's name"<<endl;
  177. outData<<"Enter the employee's name"<<endl;
  178. cin>>name;
  179. cout<<"Enter the company"<<endl;
  180. outData<<"Enter the company"<<endl;
  181. cin >> company;
  182.  
  183. ItemType obj(name,company);
  184. int length = ourList.LengthIs();
  185.  
  186. ourList.DeleteItem(obj);
  187.  
  188. for(int count = 0;count < length;count++)
  189. {
  190. ourList.GetNextItem(obj);
  191. obj.PromoteMe();
  192. ourList.InsertItem(obj);
  193. }
  194. ourList.ResetList();
  195. }
  196.  
  197. int length = ourList.LengthIs();
  198. ItemType obj(name,company);
  199. for(int count = 0;count < length;count++)
  200. {
  201. ourList.GetNextItem(obj);
  202. ourList.DeleteItem(obj);
  203. obj.PromoteMe();
  204. ourList.InsertItem(obj);
  205. }
  206.  
  207. ourList.InsertItem(obj);
  208. ourList.ResetList();
  209. }
  210.  
  211. void Promote(SortedType& ourList)
  212. {
  213. string name,company;
  214. cout<<"PROMOTE"<<endl;
  215. cout<<"Enter the employee's name"<<endl;
  216. outData<<"Enter the employee's name"<<endl;
  217. cin>>name;
  218. cout<<"Enter the company"<<endl;
  219. outData<<"Enter the company"<<endl;
  220. cin >> company;
  221.  
  222. ItemType obj(name,company);
  223. ItemType obj2(name,company);
  224. int length = ourList.LengthIs();
  225.  
  226.  
  227. ourList.DeleteItem(obj);
  228. ourList.GetNextItem(obj2);
  229. ourList.DeleteItem(obj2);
  230. ourList.InsertItem(obj2);
  231. ourList.InsertItem(obj);
  232. obj.PromoteMe();
  233. obj2.DemoteMe();
  234.  
  235. /*else
  236. {
  237. cout<<"The person is already in the top position"
  238. <<"They can not be promoted"<<endl;
  239. outData<<"The person is already in the top position"
  240. <<"They can not be promoted"<<endl;
  241. }*/
  242.  
  243. }
  244.  
  245. void Demote(SortedType& ourList)
  246. {
  247. string name,company;
  248. cout<<"DEMOTE"<<endl;
  249. cout<<"Enter the employee's name"<<endl;
  250. outData<<"Enter the employee's name"<<endl;
  251. cin>>name;
  252. cout<<"Enter the company"<<endl;
  253. outData<<"Enter the company"<<endl;
  254. cin >> company;
  255.  
  256. ItemType obj(name,company);
  257. ItemType obj2(name,company);
  258. int length = ourList.LengthIs();
  259.  
  260. //if(obj.rank < length)
  261. //{
  262. ourList.DeleteItem(obj);
  263. ourList.GetNextItem(obj2);
  264. ourList.DeleteItem(obj2);
  265. ourList.InsertItem(obj2);
  266. ourList.InsertItem(obj);
  267. obj.DemoteMe();
  268. obj2.PromoteMe();
  269. //}
  270. /*else
  271. {
  272. cout<<"The person is already in the bottom position"
  273. <<"They can not be demoted"<<endl;
  274. outData<<"The person is already in the bottom position"
  275. <<"They can not be demoted"<<endl;
  276. }*/
  277. }
  278.  
  279. void Payday(SortedType& ourList, SortedType& list2)
  280. {
  281.  
  282. cout<<"PAYDAY"<<endl;
  283. outData<<"PAYDAY"<<endl;
  284. string name,company;
  285. ItemType obj(name,company);
  286. bool okay = false;
  287. int length = ourList.LengthIs();
  288. ourList.ResetList();
  289. for(int count = 0;count < length;count++)
  290. {
  291.  
  292. ourList.GetNextItem(obj);
  293. obj.PayMe(okay);
  294. }
  295.  
  296. list2.ResetList();
  297. int size = list2.LengthIs();
  298. okay = true;
  299. for(int k = 0;k < size;k++)
  300. {
  301. list2.GetNextItem(obj);
  302. obj.PayMe(okay);
  303. }
  304. }
  305.  
  306. void Employees(SortedType& ourList)
  307. {
  308. string name,company;
  309. ItemType obj(name,company);
  310. cout<<"EMPLOYEES"<<endl;
  311. outData<<"EMPLOYEES"<<endl;
  312. cout<<"Enter the company's name:"<<endl;
  313. outData<<"Enter the company's name:"<<endl;
  314. cin>>company;
  315. ourList.ResetList();
  316. int length = ourList.LengthIs();
  317. for(int count = 0;count < length;count++)
  318. {
  319. ourList.GetNextItem(obj);
  320. obj.EPrint();
  321. }
  322. ourList.ResetList();
  323. }
  324.  
  325. void Unemployed(SortedType& list2)
  326. {
  327. string name,company;
  328. cout<<"UNEMPLOYED"<<endl;
  329. ItemType obj(name,company);;
  330. int length = list2.LengthIs();
  331. list2.ResetList();
  332. for(int count = 0;count < length;count++)
  333. {
  334. list2.GetNextItem(obj);
  335. obj.UPrint();
  336. }
  337. list2.ResetList();
  338. }
  339.  
  340. void Dump(SortedType& list2, SortedType& ourList)
  341. {
  342. string name,company;
  343. ItemType obj(name,company);
  344. cout<<"DUMP"<<endl;
  345. int length = ourList.LengthIs();
  346. cout<<"EMPLOYEES"<<endl;
  347. for(int count = 0;count < length;count++)
  348. {
  349. ourList.GetNextItem(obj);
  350. obj.EPrint();
  351. }
  352.  
  353. int length2 = list2.LengthIs();
  354. cout<<"UNEMPLOYED"<<endl;
  355. for(int k = 0;k < length2;k++)
  356. {
  357. list2.GetNextItem(obj);
  358. obj.UPrint();
  359.  
  360. }
  361. }

//ItemType.h
C++ Syntax (Toggle Plain Text)
  1.  
  2. #ifndef ITEMTYPE
  3. #define ITEMTYPE
  4. #include <string>
  5. #include <iostream>
  6. #include <fstream>
  7.  
  8. const int MAX_ITEMS = 5;
  9. using namespace std;
  10. enum RelationType {LESS, EQUAL, GREATER};
  11. class ItemType
  12. {
  13. public:
  14. //constructor
  15. ItemType(string myName,string myCompany);
  16.  
  17. RelationType ComparedTo(ItemType);
  18. //Purpose: compares objects
  19. //Precondition: self and item have their key members initalized
  20. //Postcondition:= LESS if the key of self is less then the key of item
  21. //= GREATER if the key of self is greater then the key of item
  22. //= EQUAL if the keys are equal
  23. void PromoteMe();
  24. //Function: promotes the employee
  25. //Postcondition: Employee is promoted
  26. void DemoteMe();
  27. //Function: demotes the employee
  28. //Postcondition: Employee is promoted
  29. void PayMe(bool okay);
  30. //Postcondition: pays the employees
  31. void EPrint();
  32. void UPrint();
  33.  
  34. private:
  35. ofstream outData;
  36. string company;
  37. string name;
  38. int rank;
  39. int total;
  40. };
  41.  
  42. //constructor
  43. ItemType :: ItemType(string myName, string myCompany)
  44. {
  45. name = myName;
  46. company = myCompany;
  47. rank = 1;
  48. total = 0;
  49. }
  50.  
  51. RelationType ItemType::ComparedTo(ItemType otherObj)
  52. {
  53. if((company < otherObj.company)||(company == otherObj.company)
  54. &&(rank < otherObj.rank))
  55. return LESS;
  56. else if((company > otherObj.company)||(company == otherObj.company)
  57. && (rank > otherObj.rank))
  58. return GREATER;
  59. else
  60. return EQUAL;
  61. }
  62.  
  63. void ItemType::PromoteMe()
  64. {
  65.  
  66. rank = rank+1;
  67. }
  68.  
  69. void ItemType::DemoteMe()
  70. {
  71. rank = rank-1;
  72. }
  73.  
  74. void ItemType::PayMe(bool okay)
  75. {
  76. if(!okay)
  77. total = total + rank * 1000;
  78. else
  79. total = total+ 50;
  80. }
  81.  
  82. void ItemType::EPrint()
  83. {
  84. cout<<"Name: "
  85. <<name<<endl;
  86. outData<<"Name: "
  87. <<name<<endl;
  88. cout<<"Company: "
  89. <<company<<endl;
  90. outData<<"Compnay: "
  91. <<company<<endl;
  92. cout<<"Rank: "
  93. <<rank<<endl;
  94. outData<<"Rank: "
  95. <<rank<<endl;
  96. cout<<"Total Pay: "
  97. <<total<<endl;
  98. outData<<"Total Pay: "
  99. <<total<<endl;
  100. cout<<endl;
  101. outData<<endl;
  102. }
  103.  
  104. void ItemType::UPrint()
  105. {
  106.  
  107. cout<<"Name: "
  108. <<name<<endl;
  109. outData<<"Name: "
  110. <<name<<endl;
  111. cout<<"Total Pay: "
  112. <<total<<endl;
  113. outData<<"Total Pay: "
  114. <<total<<endl;
  115. }
  116. #endif

//SortedType.h
C++ Syntax (Toggle Plain Text)
  1. #include "ItemType.h"
  2.  
  3. class SortedType
  4. {
  5. public:
  6. SortedType();
  7. bool IsFull() const;
  8. int LengthIs() const;
  9. void RetrieveItem(ItemType& item, bool& found);
  10. void InsertItem(ItemType item);
  11. void DeleteItem(ItemType item);
  12. void ResetList();
  13. void GetNextItem(ItemType& item);
  14.  
  15. private:
  16. int length;
  17. ItemType info[MAX_ITEMS];
  18. int currentPos;
  19. };
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Foxtildawn is offline Offline
15 posts
since Jan 2005
Mar 3rd, 2005
0

Re: error LNK2001: unresolved external symbol

Quote ...
any help in understanding this would be a great help
It means you are telling the compiler, "these functions will be available" -- to keep her quiet for compiling -- and then not telling the linker where to find them (or simply withholding them from her).

You are teasing the baby, and she's not happy. If you promise a function definition, provide one; otherwise, keep your mouth shut.

Or... define every function you prototype. Make good on your promises.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Mar 3rd, 2005
0

Re: error LNK2001: unresolved external symbol

>i keep getting error messages when i try to build my program
Maybe you should try reading them instead of running here every time a build fails. And you still haven't bothered to post shorter code.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: c++ SQLServer ODBC errors
Next Thread in C++ Forum Timeline: Using inputs from keyboard





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC