identifier outputlist cannot have qualifier
Code:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#define MAXPATIENTS 100
struct patient
{
char firstname[50];
char lastname[50];
char id[20];
};
class queue
{
public:
queue(void);
int addpatientatend(patient p);
int addpatientatbeginning(patient p);
patient getnextpatient(void);
int removedeadpatient(patient*p);
void outputlist(void);
char departmentname[50];
private:
int numberofpatients;
patient list[MAXPATIENTS];
};
queue::queue()
{
numberofpatients=0;
}
int queue::addpatientatend(patient p)
{
if(numberofpatients>=MAXPATIENTS)
{
return 0;
}
else
list[numberofpatients]=p; numberofpatients++;
return 1;
}
int queue::addpatientatbeginning(patient p)
{
int i;
if(numberofpatients>=MAXPATIENTS)
{
return 0;
}
for(i=numberofpatients-1;i>=0;i--)
{
list[i+1]=list[i];
}
list[0]=p;numberofpatients++;
return 1;
}
patient queue::getnextpatient(void)
{
int i; patient p;
if(numberofpatients==0)
{
strcpy(p.ID,"");
return p;
}
p=list[0];
Numberofpatient--;
for(i=0;i<numberofpatients;i++)
{
list[i]=list[i+1];
}
return p;
}
int queue::removedeadpatient(patient*p)
(
//returns 1 if successful,0 if patient not found
int i,j,found=0;
for(i=0;i<numberofpatient;++)
{
if(stricmp(list[i].ID,p->ID)==0)
{
*p=list[i];found=1;
numberofpatient--;
for(j=i;j<numberofpatients:j++)
{
list[j]=list[j+1];
}
}
}
return found;
}
void queue::outputlist(void)
{
int i;
if(numberofpatients==0)
{
cout<<"queue is empty";
}
else
{
for(i=0;i<numberofpatients;i++)
{
cout<<" "<<list[i].firstname;
cout<<" "<<list[i].lastname;
cout<<" "<<list[i].ID;
}
}
}
patient inputpatient(void)
{
patient p;
cout<<"please enter data for new patient first name:";
cin.getline(p.firstname,sizeof(p.firstname));
cout<<"last name:";
cin.getline(p.ID,sizeof(p.lastname));
cout<<"social security number:";
cin.getline(p.ID,sizeof(p.ID));
if(p.firstname[0]==0||p.lastname[0]==0||p.ID[0]==0)
{
strcpy(p.ID,"");
cout<<"error:data not valid.operation cancelled.";
getch();
}
return p;
}
void outputpatient(patient*p)
{
if(p==null||p->ID[0]==0)
{
cout<<"no patient";
return;
}
else
cout<<"patient data:";
cout<<"first name:"<<p->firstname;
cout<<"last name:"<<p->lastname;
cout<<"social security number:"<<p->ID;
}
int readnumber()
{
char buffer[20];
cin.getline(buffer,sizeof(buffer));
return atoi(buffer);
}
void departmentmenu(queue*q)
{
department
int choice=0;success;patient p;
while(choice!=6)
{
clrscr();
cout<<"welcome to department:"<<q->departmentname;
cout<<"please enter your choice:";
cout<<"1: add normal patient";
cout<<"2: add critically ill patient";
cout<<"3: take out patient for operation";
cout<<"4: remove dead patient from queue ";
cout<<"5: list queue ";
cout<<"6: change department or exit";
choice=readnumber();
switch(choice)
{
case1://add normal patient
p=inputpatient();
if(p.ID[0])
{
sucess=q->addpatientat end(p);
clrscr();
if(success)
{
cout<<"patient added:";
}
else \{
cout<<"errr :the queue is full.cannot add patient:";
}
outputpatient(&p);
cout<<"press any key";
getch();
}
break;
case2: //add critically ill patient
p=inputpatient();
if(p.ID[0])
{
success=q->addpatientat beginning(p);
clrscr();
if(success)
{
cout<<"patient added:";
}
else
{
cout<<"error:the queue is full.cannot add patient:";
}
outputpatient(&p);
cout<<"press any key";
getch();
}
break;
case3: //take out patient for operation
p=q->getnextpatient();
clrscr();
if(p.ID[0])
{
cout<<"patient to operste:";
outputpatient(&p);
}
else
{
cout<<"there is no patient to operate :";
cout<<"press any key";
getch();
break;
case4: //remove dead patient from queue
p=inputpatient();
if(p.ID[0])
{
success=q->removedeadpatient(&p);
clrscr();
if(success)
{
cout<<"patient removed:";
}
else
{
cout<<"error:cannot find patient:";
}
outputpatient(&);
cout<<"press any key";
getch();
}
break;
case5: //list queue
clrscr();
q->outputlist();
cout<<"press any key";
getch();
break;
}
}
}
void main()
{
int i,menuchoice=0;
queue departments[3];
strcpy(departments[0].departmentname,"heart clinic");
strcpy(departments[1].departmentname,"lung clinic");
strcpy(departments[2].departmentname,"plastic surgery");
while(menuchoice !=4)
{
clrscr();
cout<<"welcome to software city hospital";
cout<<"please enter your choice:";
for(i=0;i<3;i++)
{
cout<<" "<<(i+1)<<":"<<departments[i].departmentname;
}
cout<<"4: exit";
menu choice=readnumber();
if(menuchoice>=1&&menuchoice<=3)
{
departmentmenu(departments+(menuchoice-1));
}
}
}
Comment