473,382 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

programming error for coding on hospital management in c++ programming for board exam

identifier outputlist cannot have qualifier

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. #include<stdlib.h>
  5. #define MAXPATIENTS 100
  6. struct patient
  7. {
  8. char firstname[50];
  9. char lastname[50];
  10. char id[20];
  11. };
  12. class queue
  13. {
  14. public:
  15. queue(void);
  16. int addpatientatend(patient p);
  17. int addpatientatbeginning(patient p);
  18. patient getnextpatient(void);
  19. int removedeadpatient(patient*p);
  20. void outputlist(void);
  21. char departmentname[50];
  22. private:
  23. int numberofpatients;
  24. patient list[MAXPATIENTS];
  25. };
  26. queue::queue()
  27. {
  28. numberofpatients=0;
  29. }
  30. int queue::addpatientatend(patient p)
  31. {
  32. if(numberofpatients>=MAXPATIENTS)
  33. {
  34. return 0;
  35. }
  36. else
  37. list[numberofpatients]=p; numberofpatients++;
  38. return 1;
  39. }
  40. int queue::addpatientatbeginning(patient p)
  41. {
  42. int i;
  43. if(numberofpatients>=MAXPATIENTS)
  44. {
  45. return 0;
  46. }
  47. for(i=numberofpatients-1;i>=0;i--)
  48. {
  49. list[i+1]=list[i];
  50. }
  51. list[0]=p;numberofpatients++;
  52. return 1;
  53. }
  54. patient queue::getnextpatient(void)
  55. {
  56. int i; patient p;
  57. if(numberofpatients==0)
  58. {
  59. strcpy(p.ID,"");
  60. return p;
  61. }
  62. p=list[0];
  63. Numberofpatient--;
  64. for(i=0;i<numberofpatients;i++)
  65. {
  66. list[i]=list[i+1];
  67. }
  68. return p;
  69. }
  70. int queue::removedeadpatient(patient*p)
  71. (
  72. //returns 1 if successful,0 if patient not found
  73. int i,j,found=0;
  74. for(i=0;i<numberofpatient;++)
  75. {
  76. if(stricmp(list[i].ID,p->ID)==0)
  77. {
  78. *p=list[i];found=1;
  79. numberofpatient--;
  80. for(j=i;j<numberofpatients:j++)
  81. {
  82. list[j]=list[j+1];
  83. }
  84. }
  85. }
  86. return found;
  87. }
  88. void queue::outputlist(void)
  89. {
  90. int i;
  91. if(numberofpatients==0)
  92. {
  93. cout<<"queue is empty";
  94. }
  95. else
  96. {
  97. for(i=0;i<numberofpatients;i++)
  98. {
  99. cout<<" "<<list[i].firstname;
  100. cout<<" "<<list[i].lastname;
  101. cout<<" "<<list[i].ID;
  102. }
  103. }
  104. }
  105. patient inputpatient(void)
  106. {
  107. patient p;
  108. cout<<"please enter data for new patient first name:";
  109. cin.getline(p.firstname,sizeof(p.firstname));
  110. cout<<"last name:";
  111. cin.getline(p.ID,sizeof(p.lastname));
  112. cout<<"social security number:";
  113. cin.getline(p.ID,sizeof(p.ID));
  114. if(p.firstname[0]==0||p.lastname[0]==0||p.ID[0]==0)
  115. {
  116. strcpy(p.ID,"");
  117. cout<<"error:data not valid.operation cancelled.";
  118. getch();
  119. }
  120. return p;
  121. }
  122. void outputpatient(patient*p)
  123. {
  124. if(p==null||p->ID[0]==0)
  125. {
  126. cout<<"no patient";
  127. return;
  128. }
  129. else
  130. cout<<"patient data:";
  131. cout<<"first name:"<<p->firstname;
  132. cout<<"last name:"<<p->lastname;
  133. cout<<"social security number:"<<p->ID;
  134. }
  135. int readnumber()
  136. {
  137. char buffer[20];
  138. cin.getline(buffer,sizeof(buffer));
  139. return atoi(buffer);
  140. }
  141. void departmentmenu(queue*q)
  142. {
  143. department
  144. int choice=0;success;patient p;
  145. while(choice!=6)
  146. {
  147. clrscr();
  148. cout<<"welcome to department:"<<q->departmentname;
  149. cout<<"please enter your choice:";
  150. cout<<"1: add normal patient";
  151. cout<<"2: add critically ill patient";
  152. cout<<"3: take out patient for operation";
  153. cout<<"4: remove dead patient from queue ";
  154. cout<<"5: list queue ";
  155. cout<<"6: change department or exit";
  156. choice=readnumber();
  157. switch(choice)
  158. {
  159. case1://add normal  patient
  160. p=inputpatient();
  161. if(p.ID[0])
  162. {
  163. sucess=q->addpatientat end(p);
  164. clrscr();
  165. if(success)
  166. {
  167. cout<<"patient added:";
  168. }
  169. else \{
  170. cout<<"errr :the queue is full.cannot add patient:";
  171. }
  172. outputpatient(&p);
  173. cout<<"press any key";
  174. getch();
  175. }
  176. break;
  177. case2: //add critically ill patient
  178. p=inputpatient();
  179. if(p.ID[0])
  180. {
  181. success=q->addpatientat beginning(p);
  182. clrscr();
  183. if(success)
  184. {
  185. cout<<"patient added:";
  186. }
  187. else
  188. {
  189. cout<<"error:the queue is full.cannot add patient:";
  190. }
  191. outputpatient(&p);
  192. cout<<"press any key";
  193. getch();
  194. }
  195. break;
  196. case3: //take out patient for operation
  197. p=q->getnextpatient();
  198. clrscr();
  199. if(p.ID[0])
  200. {
  201. cout<<"patient to operste:";
  202. outputpatient(&p);
  203. }
  204. else
  205. {
  206. cout<<"there is no patient to operate :";
  207. cout<<"press any key";
  208. getch();
  209. break;
  210. case4: //remove dead patient from queue
  211. p=inputpatient();
  212. if(p.ID[0])
  213. {
  214. success=q->removedeadpatient(&p);
  215. clrscr();
  216. if(success)
  217. {
  218. cout<<"patient removed:";
  219. }
  220. else
  221. {
  222. cout<<"error:cannot find patient:";
  223. }
  224. outputpatient(&);
  225. cout<<"press any key";
  226. getch();
  227. }
  228. break;
  229. case5: //list queue
  230. clrscr();
  231. q->outputlist();
  232. cout<<"press any key";
  233. getch();
  234. break;
  235. }
  236. }
  237. }
  238. void main()
  239. {
  240. int i,menuchoice=0;
  241. queue departments[3];
  242. strcpy(departments[0].departmentname,"heart clinic");
  243. strcpy(departments[1].departmentname,"lung clinic");
  244. strcpy(departments[2].departmentname,"plastic surgery");
  245. while(menuchoice !=4)
  246. {
  247. clrscr();
  248. cout<<"welcome to software city hospital";
  249. cout<<"please enter your choice:";
  250. for(i=0;i<3;i++)
  251. {
  252. cout<<" "<<(i+1)<<":"<<departments[i].departmentname;
  253. }
  254. cout<<"4: exit";
  255. menu choice=readnumber();
  256. if(menuchoice>=1&&menuchoice<=3)
  257. {
  258. departmentmenu(departments+(menuchoice-1));
  259. }
  260. }
  261. }
Jan 31 '14 #1
1 2155
Banfa
9,065 Expert Mod 8TB
When I compile your code I do not get any error involving outputlist but I do get all these errors:
  • test.cpp:171:1: error: stray '\' in program
  • test.cpp: In member function 'patient queue::getnextpatient()':
  • test.cpp:61:10: error: 'struct patient' has no member named 'ID'
  • test.cpp:65:1: error: 'Numberofpatient' was not declared in this scope
  • test.cpp: At global scope:
  • test.cpp:75:7: error: 'j' has not been declared
  • test.cpp:75:9: error: 'found' has not been declared
  • test.cpp:75:15: error: default arguments are only permitted for function parameters
  • test.cpp:75:16: error: expected ')' before ';' token
  • test.cpp:75:16: error: 'removedeadpatient' declared as function returning a function
  • test.cpp:76:1: error: expected unqualified-id before 'for'
  • test.cpp:76:9: error: 'i' does not name a type
  • test.cpp:76:27: error: expected unqualified-id before '++' token
Jan 31 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All...
4
by: Ian Lazarus | last post by:
Greetings, Is there a consensus as to the best way to report a programming error, for example an out of bounds index value passed to a function? There are three approaches that I can think of: ...
0
by: mgdanedaung | last post by:
i am now a beginner of socket programming although i have a lot of programming in C# and .net I want to try a cyber cafe management program with C# i think it will need good socket programming...
1
cpiyush
by: cpiyush | last post by:
Hello, I am trying to insert values in a MySQL table using Python as front end, but facing this problem. table structure:-(Name:- namespace) Fields prifex-----------------varchar(20)...
8
by: Bhavesh1978 | last post by:
well i have my mouse working and now im trying to make my exit button working when the mouse clicked onto exit button and it will exit the application here is my coding for the mouse function to...
0
by: ankush143 | last post by:
hiii... i want to make a database for the hospital management in oracle-SQL so please help me can someone give me queries related to this.......
139
by: Joe Mayo | last post by:
I think I become more and more alone... Everybody tells me that C++ is better, because once a project becomes very large, I should be happy that it has been written in C++ and not C. I'm the only...
4
by: marmar12 | last post by:
I'm a newbie to programming and am doing this project using linux and an error message keeps popping up and i've tried everything but cannot get it fixed and compiled. Please help, its due today! ...
4
by: autiger13 | last post by:
Hi I am working on a program that will connect to a server that I input from the command line and make a request for the HTTP response. I am currently using www.yahoo.com as a test site for my...
7
by: Bil M | last post by:
I amm getting 3 errors for , please help.. error C2660: 'calculate_discount' : function does not take 1 arguments the code is #include <stdio.h> #include <conio.h>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.