4 Replies - 897 Views - Last Post: 05 February 2009 - 04:32 AM Rate Topic: -----

#1 LucidInsanity  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-February 09

Debugging help please.(Declaration terminated incorrectly)

Posted 04 February 2009 - 12:06 PM

Hi, I'm using the following program for a high school project in Computer Science. My compiler tells me that the header files are all missing and gives me a "declaration terminated incorrectly" error in the last line. I think I can probably install the header files but I really don't know what to do about the other error.I know its a very long program and there are probably a lot of errors. Any help at all will be appreciated. Thank You in advance! Also, I'm new here.
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<fstream.h>
#include<string.h>
#include<stdio.h>
class all
{
 private:
  struct address
  {
   int house;
   char street[30];
   char city[30];
   char state[30];
   char country[30];
  };
  struct age
  {
   int day;
   int month;
   int year;
  };
struct doctorinfo
{
char ward[50];
char doctorname[50];
};
struct bill
{
char typeofroom[50];
int roomfees;
int doctorfees;
int noofdays;
int total;
};
  struct patient_info
  {
   char name[50];
   address AD1;   //nested structure implemented
   age A1;		//nested structure implemented
doctorinfo DOC;
bill B1;
   int marital_status;
   int reg_no;
   int bld_group;
   int sex;
  }PI[100];
int task;
 protected:
  void enter_patient_info()
{clrscr();
ofstream ofile;
ofile.open("Storage.dat",ios::out||ios::binary||ios::app);
if(!ofile)
{
cout<<"Error, Cannot open file"<<endl;
exit(0);
}
else
{
answer='y';
 if(count==0)
 {
  serial=1;
 }
 else
 {ofile.seekg(0,ios::end);
  serial=ofile.tellg();
 }
 for(i=serial;answer=='y'||answer=='Y';i++)
 {
  PI[i].reg_no=i;
  temp=serial;
  cout<<" ***ENTERING INFORMATION FOR PATIENT SERIAL NUMBER "<<i<<"***"<<" ";
  cin.get(ch);
  cout<<" Registration Number : "<<PI[i].reg_no<<" ";
  cout<<"Enter the name of patient :"<<" ";
  clreol();
  gets(PI[i].name);
  cout<<"Sex (1-Male 2-Female) :"<<" ";
  clreol();
  cin>>PI[i].sex;
  while(PI[i].sex!=1&&PI[i].sex!=2)
  {
   cout<<"Invalid input for sex of patient!"<<" ";
   cout<<"Sex :"<<" ";
   clreol();
   cin>>PI[i].sex;
  }
  cout<<" ***ENTERING ADDRESS**"<<" ";
  cout<<"House number :"<<" ";
  clreol();
  cin>>PI[i].AD1.house;
  while(PI[i].AD1.house<=0)
  {
   cout<<"Invalid input for house number :"<<" ";
   cout<<" Enter the house number :"<<" ";
   clreol();
   cin>>PI[i].AD1.house;
  }
  cin.get(ch);
  cout<<"Street :"<<" ";
  clreol();
  cin.getline(PI[i].AD1.street,30);
  cout<<"City :"<<" ";
  clreol();
  cin.getline(PI[i].AD1.city,30);
  cout<<"State :"<<" ";
  clreol();
  cin.getline(PI[i].AD1.state,30);
  cout<<"Country :"<<" ";
  clreol();
  cin.getline(PI[i].AD1.country,30);
  DOB1.enter_date();
  cin.get(ch);
  cout<<"Marital status(1-Married,2-Not Married ):"<<" ";
  if(count!=0)
  {
   clreol();
  }
  cin>>PI[i].marital_status;
  while(PI[i].marital_status<1||PI[i].marital_status>2)
  {
   cout<<"Invalid input for marital status ."<<" ";
   cout<<"Enter a valid marital status :"<<" ";
   clreol();
   cin>>PI[i].marital_status;
  }
  cin.get(ch);
  if(count!=0)
  {
   clreol();
  }
  clreol();
  cout<<"Blood group :"<<" ";
  clreol();
  cout<<"1. A+ "<<" ";
  clreol();
  cout<<"2. A- "<<" ";
  clreol();
  cout<<"3. B+ "<<" ";
  clreol();
  cout<<"4. B- "<<" ";
  clreol();
  cout<<"5. AB+ "<<" ";
  clreol();
  cout<<"6. AB- "<<" ";
  clreol();
  cout<<"7. O+ "<<" ";
  clreol();
  cout<<"8. O- "<<" ";
  clreol();
  cout<<"Enter :"<<" ";
  clreol();
  cin>>PI[i].bld_group;
  switch(PI[i].bld_group)
  {
   case 1:
   case 2:
   case 3:
   case 4:
   case 5:
   case 6:
   case 7:
   case 8:{
		   break;
		  }
  default:{

while(PI[i].bld_group!=1&&PI[i].bld_group!=2&&PI[i].bld_group!=3&&

PI[i].bld_group!=4&&PI[i].bld_group!=5&&PI[i].bld_group!=6&&
				 PI[i].bld_group!=7&&PI[i].bld_group!=8)
		   {
			clreol();
			cout<<"Invalid input !"<<" ";
			cout<<"Blood Group :"<<" ";
			clreol();
			cin>>PI[i].bld_group;
		   }
		   break;
		  }
  }
cout<<"Enter the patient’s ward "<<endl;
cout<<"Menu"<<endl;
cout<<"1. General Ward"<<endl<<"2. Maternity Ward"<<endl<<"3. ICU Ward"<<endl<<"4. Cardiac Ward"<<endl<<"5. Infertility Ward"<<endl;

int choice;
do{switch(choice)
{
case 1: {strcpy(P1.DOC.Ward,"General Ward");
			P1[i].B1.doctorfees=500;break;}
case 2: {strcpy(P1.DOC.Ward,"Maternity Ward");
			P1[i].B1.doctorfees=2000;break;}
case 3:{ strcpy(P1.DOC.Ward,"ICU Ward");
			P1[i].B1.doctorfees=5000;break;}
case 4: {strcpy(P1.DOC.Ward,"Cardiac Ward");
			P1[i].B1.doctorfees=4000;break;}
case 5: {strcpy(P1.DOC.Ward,"Infertility Ward");
			P1[i].B1.doctorfees=6000;break;}
Default: cout<<"Invalid, Re-enter"<<endl;
cin>>choice;}}while(choice);
cout<<"Enter doctor’s name: "<<endl;
gets(P1[i].DOC.doctorname);
cout<<"Enter room"<<endl;
cout<<"Menu:"<<endl;
cout<<"1. Double Deluxe"<<endl<<"2. Deluxe"<<endl<<"3. Regular"<<endl<<"4. Out Patient"<<endl;
int choice1;
do{switch(choice1)
{
case 1:{strcpy(P1[i].B1.typeofroom,"Double Deluxe");
		   P1[i].B1.roomfees=5000;break;}
case 2: {strcpy(P1[i].B1.typeofroom,"Deluxe");
		   P1[i].B1.roomfees=2000;break;}
case 3: {strcpy(P1[i].B1.typeofroom,"Regular");
		   P1[i].B1.roomfees=500;break;}
case 4: {strcpy(P1[i].B1.typeofroom,"Out Patient");
		   P1[i].B1.roomfees=0;break;}

default: "Invalid, Re-enter"<<endl;
cin>>choice1;}}while(choice1);
  cin.get(ch);
  cout<<"Do you want to enter information for another patient ? "<<" ";
  clreol();
  cin>>answer;
  count++;
  serial++;
ofile.write((char*)&P1[i],sizeof(P1[i])); }}
ofile.close();
 clrscr();
 A1.tasks();
}
void show_patient_detail()
{int i;
i=0;
ifstream ifile;
ifile.open("Storage.dat",ios::in||ios::binary);
if(!ifile)
{
cout<<"Error,Cannot Open"<<endl;
exit(0);
}
else
{
 do
 {
  clrscr();
  cout<<"Enter registration number :"<<" ";
  clreol();
  cin>>regis;
  cin.get(ch);
while(ifile)
{ ifile.read((char*)&P1[i],sizeof(P1[i]));
if(P1[i].reg_no==regis)
{
  show_count++;
	{ifile.read((char*)&P1[i],sizeof(P1[i]));
   clreol();
   cout<<"***INFORMATION FOR PATIENT REGISTRATION NUMBER"<<i<<"*** ";
   clreol();
   cout<<"Name		   : "<<PI[i].name<<" ";
   clreol();
   cout<<"Sex			: ";
   clreol();
   if(PI[i].sex==1)
   {
	cout<<"Male "<<" ";
	clreol();
   }
   if(PI[i].sex==2)
   {
	cout<<"Female "<<" ";
	clreol();
   }
   cout<<"Blood Group	: ";
   clreol();
   switch(PI[i].bld_group)
   {
	case 1:{
			clreol();
			cout<<"A+ ";
			break;
		   }
	case 2:{
			clreol();
			cout<<"A- ";
			break;
		   }
	case 3:{
			clreol();
			cout<<"B+ ";
			break;
		   }
	case 4:{
			clreol();
			cout<<"B- ";
			break;
		   }
	case 5:{
			clreol();
			cout<<"AB+ ";
			break;
		   }
	case 6:{
			clreol();
			cout<<"AB- ";
			break;
		   }
	case 7:{
			clreol();
			cout<<"O+ ";
			break;
		   }
	case 8:{
			clreol();
			cout<<"O- ";
			break;
		   }
   }
   clreol();
   cout<<"Date of birth  : ";
   clreol();
   DOB1.show_date();
   cout<<"Marital Status : ";
   clreol();
   if(PI[i].marital_status==1)
   {
	cout<<"Married "<<"  ";
	clreol();
   }
   else
   {
	cout<<"Not married "<<" ";
	clreol();
   }
   clreol();
   cout<<" **ADDRESS**"<<" ";
   clreol();
   cout<<" House no.	  : "<<PI[i].AD1.house;
   clreol();
   cout<<" Street		 : "<<PI[i].AD1.street;
   clreol();
   cout<<" City		   : "<<PI[i].AD1.city;
   clreol();
   cout<<" State		  : "<<PI[i].AD1.state;
   clreol();
   cout<<" Country		: "<<PI[i].AD1.country;
   clreol();
  }
else
{i++;}
 if(!show_count)
{cout<<" File Not Found "<<" ";}
 cout<<"Press any key to exit to main task menu"<<" ";
	getch();
	clrscr();
	A1.tasks();
   }

}

   clreol();
  cout<<" Do you want to see information of another patient? "<<" ";
  clreol();
  cin>>answer1;
 }while(answer1=='y'||answer1=='Y');
 clreol();
 clrscr();
 A1.tasks();
ifile.close();}
int calculate()
{ ifstream ifile;
ifile.open("Storage.dat",ios::in||ios::binary);
int regis1;
while(ifile)
{ ifile.read((char*)&P1[i],sizeof(P1[i]));
if(P1[i].reg_no==regis1)
{cout<<"Enter the number of days the Patient has stayed:"<<endl;
cin>> P1[i].B1.noofdays;
P1[i].B1.total=(P[i].B1.noofdays*P1.B1.doctorfees)+(P1[i].B1.noofdays*P1[i].B1.roomfees);
return(P1[i].B1.total); }
else{i++;}
ifile.close();}
void discharge_summary()
{ int count;
ifstream ifile;
ifile.open("Storage.dat",ios::in||ios::binary);
int regis1;
while(ifile)
{
count++;
ifile.read((char*)&P1[i],sizeof(P1[i]));
if(P1[i].reg_no==regis1)
{cout<<"Discharge Summary:"<<endl;
int total1=calculate();
void show_patient_detail();
cout<<"Ward: "<<P1[i].DOC.ward<<endl;
cout<<"Doctor Name"<<P1[i].DOC.doctorname<<endl;
cout<<"Doctor Fees (per day): "<<P1[i].B1.doctorfees<<endl;
cout<<"Room Fees (per day)"<<P1[i].B1.roomfees<<endl;
cout<<"Number Of Days:"<<P1[i].B1.noofdays<<endl;
cout<<"Total Fees: "<<total1<<endl;
cout<<"Thank You For Visiting XYZ Hospital"<<endl;
cout<<"Stay Healthy!"<<endl;
}
else{i++;}
{if(!count)
{cout<<" File Not Found "<<" ";}
 cout<<"Press any key to exit to main task menu"<<" ";
	getch();
	clrscr();
	A1.tasks();
   }
	  }
}
public:
void tasks();
  char answer;
  char answer1;
  char ch;
  int serial;
};
class date
{
 private:
 	int date;
   int month;
   int year;
 public:
   void enter_date()
{ cout<<" Enter today’s date:"<<" ";
 cout<<"Year :";
 cin>>year;
 if(year<=0||year>10000)
 {
  do
  {
   cout<<"Invalid input for year !"<<" ";
   cout<<"Please enter the year correctly :"<<" ";
   cin>>year;
  }while(year<0||year>10000);
 }
 cout<<"Month :";
 cin>>month;
 if(month<=0||month>12)
 {
  do
  {
   cout<<"Invalid input for month !"<<" ";
   cout<<"Enter the month :"<<" ";
   cin>>month;
  }while(month<0||month>12);
 }
 cout<<"Date :";
 switch(month)
 {
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:{
		   cin>>date;
		   while(date<1||date>31)
		   {
			cout<<"Invalid date !"<<" ";
			cout<<"Enter the date :"<<" ";
			cin>>date;
		   }
		   break;
		  }
  case 2:{
		  cin>>date;
		  if(year%4==0)
		  {
		   while(date<0||date>29)
		   {
			cout<<"Invalid date !"<<" ";
			cout<<"Enter the date :"<<" ";
			cin>>date;
		   }
		  }
		  else
		  {
		   while(date<0||date>28)
		   {
			cout<<"Invalid date !"<<" ";
			cout<<"Again enter the date :"<<" ";
			cin>>date;
		   }
		  }
		  break;
		 }
 default:{
		  cin>>date;
		  while(date<1||date>30)
		  {
		   cout<<"Invalid date !"<<" ";
		   cout<<"Enter the date :"<<" ";
		   cin>>date;
		  }
		  break;
		 }
 }
}

   void show_date()
{ clrscr();
 cout<<"Hello....It's ";
 cout<<date;
 rem=date%10;
 switch(date)
 {
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
  case 16:
  case 17:
  case 18:
  case 19:
  case 20:{
		   cout<<"th ";
		 break;
		  }
 }
 switch(rem)
 {
  case 1:{
		  cout<<"st ";
		  break;
		 }
  case 2:{
		  cout<<"nd ";
		  break;
		 }
  case 3:{
		  cout<<"rd ";
		  break;
		 }
 default:{
		  cout<<"th ";
		  break;
		 }
 }
 over:
 switch(month)
 {
  case 1:{
		  cout<<"January , ";
		  break;
		 }
  case 2:{
		  cout<<"February , ";
		  break;
		 }
  case 3:{
		  cout<<"March , ";
		  break;
		 }
  case 4:{
		  cout<<"April , ";
		  break;
		 }
  case 5:{
		  cout<<"May , ";
		  break;
		 }
  case 6:{
		  cout<<"June , ";
		  break;
		 }
  case 7:{
		  cout<<"July , ";
		  break;
		 }
  case 8:{
		  cout<<"August , ";
		  break;
		 }
  case 9:{
		  cout<<"September , ";
		  break;
		 }
 case 10:{
		  cout<<"October , ";
		  break;
		 }
 case 11:{
		  cout<<"November , ";
		  break;
		 }
 case 12:{
		  cout<<"December , ";
		  break;
		 }
 }
 cout<<year<<"  ";
}

};
class dob
{
 private:
  struct dob1
  {
   int date;
   int month;
   int year;
   int rem;
  }DOB11[100];
 public:
   void enter_date()
{
clreol();
 cout<<"Date of birth"<<" ";
 clreol();
 cout<<"Year :";
 clreol();
 clreol();
 cin>>DOB11[temp].year;
 if(DOB11[temp].year<=0||DOB11[temp].year>10000)
 {
  do
  {
   clreol();
   cout<<"Invalid input for year !"<<" ";
   cout<<"Please enter the year correctly :"<<" ";
   cin>>DOB11[temp].year;
  }while(DOB11[temp].year<0||DOB11[temp].year>10000);
 }
 clreol();
 cout<<"Month :";
 clreol();
 cin>>DOB11[temp].month;
 if(DOB11[temp].month<=0||DOB11[temp].month>12)
 {
  do
  {
   clreol();
   cout<<"Invalid input for month !"<<" ";
   cout<<"Enter the month :"<<" ";
   clreol();
   if(count!=0)
   {
	clreol();
   }
   cin>>DOB11[temp].month;
  }while(DOB11[temp].month<0||DOB11[temp].month>12);
 }
 cout<<"Date :";
 clreol();
 switch(DOB11[temp].month)
 {
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:{
		   cin>>DOB11[temp].date;
		   while(DOB11[temp].date<1||DOB11[temp].date>31)
		   {
			clreol();
			cout<<"Invalid date !"<<" ";
			cout<<"Enter the date :"<<" ";
			clreol();
			cin>>DOB11[temp].date;
		   }
			break;
		  }
  case 2:{
		  cin>>DOB11[temp].date;
		  if(DOB11[temp].year%4==0)
		  {
		   while(DOB11[temp].date<0||DOB11[temp].date>29)
		   {
			clreol();
			cout<<"Invalid date !"<<" ";
			cout<<"Enter the date :"<<" ";
			clreol();
			cin>>DOB11[temp].date;
		   }
		  }
		  else
		  {
		   while(DOB11[temp].date<0||DOB11[temp].date>28)
		   {
			clreol();
			cout<<"Invalid date !"<<" ";
			cout<< "Enter the date :"<<" ";
			clreol();
			cin>>DOB11[temp].date;
		   }
		  }
		  break;
		 }
 default:{
		  cin>>DOB11[temp].date;
		  while(DOB11[temp].date<1||DOB11[temp].date>30)
		  {
		   clreol();
		   cout<<"Invalid date !"<<" ";
		   cout<<"Enter the date :"<<" ";
		   clreol();
		   cin>>DOB11[temp].date;
		  }
		  break;
		 }
 }
 clreol();
}
void show_date()
{ clrscr();
 cout<<"Hello....It's ";
 cout<<date;
 rem=date%10;
 switch(date)
 {
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
  case 16:
  case 17:
  case 18:
  case 19:
  case 20:{
		   cout<<"th ";
		 break;
		  }
 }
 switch(rem)
 {
  case 1:{
		  cout<<"st ";
		  break;
		 }
  case 2:{
		  cout<<"nd ";
		  break;
		 }
  case 3:{
		  cout<<"rd ";
		  break;
		 }
 default:{
		  cout<<"th ";
		  break;
		 }
 }
 over:
 switch(month)
 {
  case 1:{
		  cout<<"January , ";
		  break;
		 }
  case 2:{
		  cout<<"February , ";
		  break;
		 }
  case 3:{
		  cout<<"March , ";
		  break;
		 }
  case 4:{
		  cout<<"April , ";
		  break;
		 }
  case 5:{
		  cout<<"May , ";
		  break;
		 }
  case 6:{
		  cout<<"June , ";
		  break;
		 }
  case 7:{
		  cout<<"July , ";
		  break;
		 }
  case 8:{
		  cout<<"August , ";
		  break;
		 }
  case 9:{
		  cout<<"September , ";
		  break;
		 }
 case 10:{
		  cout<<"October , ";
		  break;
		 }
 case 11:{
		  cout<<"November , ";
		  break;
		 }
 case 12:{
		  cout<<"December , ";
		  break;
		 }
 }
 cout<<year<<"  ";
}

};
int i=0;
int rem;
int count;
int regis;
int attempt;
int temp;
int show_count=0;
all A1;		   //object declared
date D1;		  //object declared
dob DOB1;		 //object declared
void main()
{
count=0;
 cout<<"Welcome to..."<<" ";
 cout<<" *** XYZ HOSPITAL***"<<" ";
D1.enter_date();
 A1.tasks();
}
void all::tasks()
{
D1.show_date();
 cout<<"***HOSPITAL MANAGEMENT ***"<<" ";
cout<<" **Tasks**"<<endl;
cout<<" Please  select a task to do...."<<" ";
 cout<<" 1. Enter information for new patient "<<" "<<endl;
 cout<<"2. View details of existing patient "<<" "<<endl;
cout<<"3. View Discharge Summary"<<" "<<endl;
  cout<<"4. Exit from the program"<<" "<<endl;
cout<<"Enter your task serial:"<<" ";
 cin>>task;
 switch(task)
 {
  case 1:{
		  A1.enter_patient_info();

		  break;
		 }
  case 2:{
		  A1.show_patient_detail();
		  break;
		 }
case 3: {
			 A1.discharge_summary();
			 break;}
case 4:{
		  clrscr();
		  cout<<" Thank You!"<<"  ";
		  cout<<"	The End!	  "<<"  ";
		  cout<<" Press any key to exit....."<<"  ";
		  getch();
		  exit(0);
		  break;
		 }
 default:{
		  clrscr();
		  cout<<" Invalid task"<<" ";
		  cout<<"Press any key to continue...."<<" ";
		  getch();
		  clrscr();
		  A1.tasks();
		 }
 }
}



Is This A Good Question/Topic? 0
  • +

Replies To: Debugging help please.(Declaration terminated incorrectly)

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,515
  • Joined: 23-August 08

Re: Debugging help please.(Declaration terminated incorrectly)

Posted 04 February 2009 - 12:33 PM

So you found this code on the net (including here at D.I.C.), but you can't figure out how to compile it, right?
Was This Post Helpful? 0
  • +
  • -

#3 LucidInsanity  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-February 09

Re: Debugging help please.(Declaration terminated incorrectly)

Posted 04 February 2009 - 07:23 PM

I found a portion of it somewhere. I have added some more functions and integrated it with with file handling. Please read all of it.
Was This Post Helpful? 0
  • +
  • -

#4 LucidInsanity  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-February 09

Re: Debugging help please.(Declaration terminated incorrectly)

Posted 04 February 2009 - 07:41 PM

A large portion of it actually and I tried to mess around with it a bit and add things but I just made it not work.
Was This Post Helpful? 0
  • +
  • -

#5 LucidInsanity  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-February 09

Re: Debugging help please.(Declaration terminated incorrectly)

Posted 05 February 2009 - 04:32 AM

I found the errors. It was just a whole load of unmatched {}s. Thanks anyway.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1