Function Error Message Help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2005
Posts: 15
Reputation: Foxtildawn is an unknown quantity at this point 
Solved Threads: 0
Foxtildawn Foxtildawn is offline Offline
Newbie Poster

Function Error Message Help

 
0
  #1
Mar 2nd, 2005
I keep getting this error message and I cant figure out how to fix it. Im not sure whether I have been trying to fix it for to long or somehting that maybe im not seeing the problem:

ItemType::ItemType' : error in function definition or declaration; function not called

it says the same thing for my PromoteMe,DemoteMe,EPrint,UPrint functions when i try to use them in my EmpType.ccp.

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

//EmpType.ccp
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4. #include "SortedType.h"
  5. #include "ItemType.h"
  6.  
  7.  
  8. ofstream outData;
  9. enum CommandType {JOIN,QUIT,CHANGE,PROMOTE,DEMOTE,
  10. PAYDAY,EMPLOYEES,UNEMPLOYED,DUMP,END};
  11. void Join(SortedType&);
  12. void GetCommand(CommandType&);
  13. void Quit(SortedType&,SortedType&);
  14. void Change(SortedType&);
  15. void Unemployed(SortedType&);
  16. void Dump(SortedType&,SortedType&);
  17. void Employees(SortedType&);
  18. void Payday(SortedType&,SortedType&);
  19. void Demote(SortedType&);
  20. void Promote(SortedType&);
  21.  
  22. void main()
  23. {
  24. using namespace std;
  25. cout<<"Welcome to the Employee Program"<<endl;
  26. CommandType command;
  27. SortedType ourList,list2;
  28.  
  29. outData.open("data.dat");
  30. GetCommand(command);
  31. while(command != END)
  32. {
  33. switch(command)
  34. {
  35. case JOIN: Join(ourList);break;
  36. case QUIT: Quit(ourList,list2);break;
  37. case CHANGE: Change(ourList);break;
  38. case PROMOTE: Promote(ourList);break;
  39. case DEMOTE: Demote(ourList);break;
  40. case PAYDAY: Payday(ourList,list2);break;
  41. case EMPLOYEES: Employees(ourList);break;
  42. case UNEMPLOYED: Unemployed(list2);break;
  43. case DUMP: Dump(ourList,list2);break;
  44. }
  45. GetCommand(command);
  46. }
  47.  
  48. }
  49.  
  50. void GetCommand(CommandType& command)
  51. {
  52.  
  53. cout<<"EMPLOYEE MENU PROGRAM"<<endl;
  54. outData<<"EMPLOYEE MENU PROGRAM"<<endl;
  55. cout<<"Type in a Capitial letter from the choices below then press ENTER"<<endl;
  56. outData<<"Type in a Capitial letter from the choices below then press ENTER"<<endl;
  57. cout<<endl;
  58. outData<<endl;
  59. cout<<" J: A person joins a new company."<<endl;
  60. outData<<" J: A person joins a new company."<<endl;
  61. cout<<" Q: A person quits a company."<<endl;
  62. outData<<" Q: A person quits a company."<<endl;
  63. cout<<" C: A person quits their job and joins a different company."<<endl;
  64. outData<<" C: A person quits their job and joins a different company."<<endl;
  65. cout<<" P: A person is promoted."<<endl;
  66. outData<<" P: A person is promoted."<<endl;
  67. cout<<" D: A person is demoted."<<endl;
  68. outData<<" D: A person is demoted."<<endl;
  69. cout<<" M: payday."<<endl;
  70. outData<<" M: payday."<<endl;
  71. cout<<" E: Print list of employees in a company."<<endl;
  72. outData<<" E: Print list of employees in a company."<<endl;
  73. cout<<" U: Print list of unemployeed people."<<endl;
  74. outData<<" U: Print list of unemployeed people."<<endl;
  75. cout<<" A: Print both employee and unemployeed list."<<endl;
  76. outData<<" A: Print both employee and unemployeed list."<<endl;
  77. cout<<" X: END OF PROGRAM"<<endl;
  78. outData<<" X: END OF PROGRAM"<<endl;
  79. char letter;
  80. cin>>letter;
  81. cout<<endl;
  82.  
  83. bool okay = false;
  84. while(!okay)
  85. {
  86. okay = true;
  87. switch(letter)
  88. {
  89.  
  90. case 'J': command = JOIN; break;
  91. case 'Q': command = QUIT; break;
  92. case 'C': command = CHANGE; break;
  93. case 'P': command = PROMOTE;break;
  94. case 'D': command = DEMOTE;break;
  95. case 'M': command = PAYDAY; break;
  96. case 'E': command = EMPLOYEES; break;
  97. case 'U': command = UNEMPLOYED; break;
  98. case 'A': command = DUMP;break;
  99. case 'X': command = END;break;
  100. default: cout<<"Letter Entered was not one"
  101. <<" of the choices above. ENTER"
  102. <<" another Letter then press return: "<<endl;
  103. outData<<"Letter Entered was not one"
  104. <<" of the choices above. ENTER"
  105. <<" another Letter then press return: "<<endl;
  106. cin>>letter;
  107. okay = false;
  108. }
  109. }
  110. }
  111.  
  112. void Join(SortedType& ourList,SortedType& list2)
  113. {
  114. bool check = false;
  115. string name,company;
  116. cout<<"Enter the employee's name"<<endl;
  117. outData<<"Enter the employee's name"<<endl;
  118. cin>>name;
  119. cout<<"Enter the company"<<endl;
  120. outData<<"Enter the company"<<endl;
  121. cin >> company;
  122.  
  123. ItemType obj(name,company);
  124. int length = ourList.LengthIs();
  125.  
  126. if(list2.RetrieveItem(obj,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. if(obj.rank < length)
  227. {
  228. ourList.DeleteItem(obj);
  229. ourList.GetNextItem(obj2);
  230. ourList.DeleteItem(obj2);
  231. ourList.InsertItem(obj2);
  232. ourList.InsertItem(obj);
  233. obj.PromoteMe();
  234. obj2.DemoteMe();
  235. }
  236. else
  237. {
  238. cout<<"The person is already in the top position"
  239. <<"They can not be promoted"<<endl;
  240. outData<<"The person is already in the top position"
  241. <<"They can not be promoted"<<endl;
  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. }
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,734
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 738
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Function Error Message Help

 
0
  #2
Mar 2nd, 2005
One of these characters doesn't belong. Can you find it?
void ItemType::PayMe(bool okay);
{
  if(!okay)
    total = total + rank * 1000;
  else
    total = total+ 50;
}
Sadly, I don't have your other header, and I'm too lazy to go through all the code you posted. So why don't you hack and slash your code so that it's smaller and doesn't rely on mystery headers and post it again.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 15
Reputation: Foxtildawn is an unknown quantity at this point 
Solved Threads: 0
Foxtildawn Foxtildawn is offline Offline
Newbie Poster

Re: Function Error Message Help

 
0
  #3
Mar 2nd, 2005
I dont understand what u exactly want me to do but here is the other header:
Thanks

  1. #include "ItemType.h"
  2. // File ItemType.h must be provided by the user of this class.
  3. // ItemType.h must contain the following definitions:
  4. // MAX_ITEMS: the maximum number of items on the list
  5. // ItemType: the definition of the objects on the list
  6. // RelationType: {LESS, GREATER, EQUAL}
  7. // Member function ComparedTo(ItemType item) which returns
  8. // LESS, if self "comes before" item
  9. // GREATER, if self "comes after" item
  10. // EQUAL, if self and item are the same
  11.  
  12. class SortedType
  13. {
  14. public:
  15. SortedType();
  16. bool IsFull() const;
  17. int LengthIs() const;
  18. void RetrieveItem(ItemType& item, bool& found);
  19. void InsertItem(ItemType item);
  20. void DeleteItem(ItemType item);
  21. void ResetList();
  22. void GetNextItem(ItemType& item);
  23.  
  24.  
  25. private:
  26. int length;
  27. ItemType info[MAX_ITEMS];
  28. int currentPos;
  29. };
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,734
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 738
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Function Error Message Help

 
0
  #4
Mar 2nd, 2005
>I dont understand what u exactly want me to do
Make less code with same problem. How hard is that?

>but here is the other header
You're including ItemType.h twice. That's a big no-no if your headers have definitions. Do this:
  1. #ifndef ITEMTYPE
  2. #define ITEMTYPE
  3.  
  4. // Contents of ItemType.h here
  5.  
  6. #endif
That's a Band-Aid to get you to the real problems. Have fun.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC