C++ error removal, declaration terminated incorrectly

I keep getting 'declaration terminated incorrectly' when I exe

Page 1 of 1

3 Replies - 2296 Views - Last Post: 26 October 2009 - 06:44 AM Rate Topic: -----

#1 cipher1729  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 26-October 09

C++ error removal, declaration terminated incorrectly

Posted 26 October 2009 - 03:05 AM

#include<fstream.h>
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
#include<string.h>

//in all examples with 'int accno' as parameter
//assume  accno is the account no of the user
//which must be known to us

//GENERAL FUNCTION PROTOTYPES
const char TL=218,TR=191,BL=192,BR=217,HL=196,VL=179;
void add();
void display(int);
void search(int);
void del(int);
void modify(int);
void deposit(int);
void withdraw(int);
void DispCh(int C,int R,char Ch);
void DispCh(int C,int R,char Ch[]);
void Color(int TC,int TB);
void Recta(int C1,int R1,int C2,int R2);
int VMenu(int C,int R,char Men[][15],int Noo);
int HMenu(int C,int R,char Men[][15],int Noo);


//MAIN CLASS
class Account_holder
{ int accno;
  char name[40];
  char add[100];
  char mob[230];
  char email[50];
  float depamt;
  float balance;

  public:
	int retacc()
		{   return accno;
		}


	void moddepamt(int amt)
	{
	depamt+=amt;

	}

	void modwithamt(int amt)
  {
	depamt-=amt;

  }


void Input()
	{ cout<<"ACCNO		   ?"<<endl;cin>>accno;
	cout<<  "NAME			?"<<endl;gets(name);
	cout<<  "ADDRESS		 ?"<<endl;gets(add);
	cout<<  "MOBILE NO	   ?"<<endl;gets(mob);
	cout<<  "EMAIL		   ?"<<endl;gets(email);
	cout<<  "INITIAL AMOUNT YOU WANT TO DEPOSIT :";cin>>depamt;
	clrscr();
	Disp();
	}

void Disp()
{   cout<<  "ACCNO		   "<<accno<<endl;
	cout<<  "NAME			";puts(name);
	cout<<  "ADDRESS		 ";puts(add);
	cout<<  "MOBILE NO	   ";puts(mob);
	cout<<  "EMAIL		   ";puts(email);
	cout<<  "BALANCE		 "<<depamt;
	  cout<<endl;
}



void mod()
 {cout<<"What do you want to modify?"<<endl;
  cout<<"a.Name b.Address c.Mobile No  d.email  e.Amount deposited:"<<endl;
  char ch;
  cin>>ch;
  switch (ch)
   {	  case 'a':gets(name);
		break;
	  case 'b':gets(add);
		break;
	  case 'c':gets(mob);
		break;
	  case 'd':gets(email);
		break;
	  case 'e':cin>>depamt;
		break;
	};
}
	//BINARY FILE FUNCTIONS




void add()
{
	fstream f;
	Account_holder a;
	f.open("Master.dat",ios::out|ios::binary|ios::app);
	{
		 a.Input();
		 f.write((char*)&a,sizeof(a));
	}
}
void display(int accno)
{
	fstream f;
	Account_holder a;
	f.open("Master.dat",ios::in|ios::binary|ios::app);
	while(f.read((char*)&a,sizeof(a)))
	{	if (a.retacc()==accno)
		a.Disp();
	}

}


void search(int accno)
{
	fstream f;
	Account_holder a;
	int found=0;
	f.open("Master.dat" ,ios::binary||ios::in|ios::app);

	while(f.read((char*)&a,sizeof(a)))
	{
		if(a.retacc()==accno)	// create function to return accno of a
		a.Disp();
		found++;
	}
	if (found==0)
	cout<<"Record not found"<<endl;
	f.close();
}


void del(int accno)
{
	fstream f1,f2;
	Account_holder a;
	int dele=0;
	f1.open("Master.dat",ios::binary|ios::in|ios::app);
	f2.open("temp.dat",ios::binary|ios::out|ios::app);
	while(f1.read((char*)&a,sizeof(a)))
	{
		if(a.retacc()!=accno)
		f2.write((char*)&a,sizeof(a));
		   else
		   dele++;
	}
	if(!dele)
	cout<<"account not found";
	else
	cout<<"account deleted";
	delete("master.dat");
	rename("temp.dat","Master.dat");

	f1.close();
	f2.close();

}


void modify(int accno)
{			 fstream f;
		  f.open("Master.dat",ios::binary||ios::in|ios::out|ios::app);
		  Account_holder a;
		  int found=0;
		  while(!found && f.read((char*)&a,sizeof(a)))
		if(a.retacc()==accno) found++;
		if(found)
		{
			a.modify();
		int n=f.tellg()-sizeof(a);
		f.seekp(n);
		f.write((char*)&a,sizeof(a));
		  }
	else
	 cout<<"No account matching the editing"<<endl;
	 f.close();
}


void deposit(int accno)
{
	int amt;
	cout<<"enter amount to be deposited:";
	cin>>amt;
	Account_holder a;
	fstream f;
	f.open("master.dat",ios::out|ios::app|ios::binary);
	while(f.read((char*)&a,sizeof(a)))
	{
		if(a.retacc()==accno)
		 a.moddepamt(amt);
	}
	   f.close();
}



void withdraw(int accno)
{
	int amt;
	cout<<"enter amount to be withdrawn:";
	cin>>amt;
	Account_holder a;
	fstream f;
	f.open("master.dat",ios::out|ios::app|ios::binary);
	while(f.read((char*)&a,sizeof(a)))
	{
		if(a.retacc()==accno)
		 a.modwithamt(amt);
	}
	   f.close();
}


//GENERAL FUNCTIONS
void DispCh(int C,int R,char Ch)
{
  gotoxy(C,R);cprintf("%c",Ch);//C 1-80 R 1-25
}

void DispCh(int C,int R,char S[])
{
  gotoxy(C,R);cprintf("%s",S);
}

void Color(int TC,int TB)
{
  textcolor(TC);
  textbackground(TB);
}
void Recta(int C1,int R1,int C2,int R2)
{
  DispCh(C1,R1,TL);	 //		  	 
  DispCh(C2,R1,TR);
  DispCh(C1,R2,BL);	 //		  	 
  DispCh(C2,R2,BR);
  for (int i=C1+1;i<C2;i++)
  {
	DispCh(i,R1,HL);
	DispCh(i,R2,HL);
  }
  for (i=R1+1;i<R2;i++)
  {
	DispCh(C1,i,VL);
	DispCh(C2,i,VL);
  }
}

int VMenu(int C,int R,char Men[][15],int Noo)
{
  Color(YELLOW,BLUE);
  Recta(C,R,C+strlen(Men[0])+1,R+Noo+1);//Drawing a rectangle enclosing options
  for (int i=0;i<Noo;i++)
	DispCh(C+1,R+i+1,Men[i]);		   //Displaying All options

  int Exit=0,Sel=0;

  do
  {
	int Tsel=Sel;
	Color(BLUE,YELLOW);		  //Changing color for highlighting
	DispCh(C+1,R+Sel+1,Men[Sel]);//Redisplaying the selected option with changed color
	Color(YELLOW,BLUE);		  //Changing color to normal
	char Ch=getch();			 //Accepting option from user
	switch(Ch)
	{
	case 71:Sel=0;break;		//Home -> Move to first option
	case 79:Sel=Noo-1;break;	//End  -> Move to Last option
	case 72:if (Sel==0)		 //Up   -> Checking if already on top
		  Sel=Noo-1;		//		Move to the last option
		else				//
		  Sel--;			//		Move one option up
		break;
	case 80:if (Sel==Noo-1)	 //Down -> Checking if already at bottom
		  Sel=0;			//		Move to the first option
		else				//
		  Sel++;			//		Move one step down
		break;
	case 27:Sel=-1;	  //Escape-> Getting out of the Menu without valid selection
	case 13:Exit=1;	  //Enter-> Getting out of the Menu with current selection
	}
	DispCh(C+1,R+Tsel+1,Men[Tsel]);//Redisplaying the non-highlighted option
  }
  while (!Exit);
  return Sel;			 //Returning the selected value from menu
}
int HMenu(int C,int R,char Men[][15],int Noo)
{
  int Exit=0,Sel=0;
  Color(YELLOW,BLUE);
  for (int i=0;i<Noo;i++)
	DispCh(C+10*i+1,R,Men[i]);
  do
  {
	int Tsel=Sel;
	Color(BLUE,YELLOW);
	DispCh(C+10*Sel+1,R,Men[Sel]);
	Color(YELLOW,BLUE);
	char Ch=getch();
	switch(Ch)
	{
	case 71:Sel=0;break;	 //Home
	case 79:Sel=Noo-1;break; //End
	case 75:if (Sel==0)	  //Left
	  Sel=Noo-1;
	else
	  Sel--;
	break;
	case 77:if (Sel==Noo-1)  //Right
	  Sel=0;
	else
	  Sel++;
	break;
	case 27:Sel=-1;	//Escape
	case 13:Exit=1;   //Enter
	}
	DispCh(C+10*Tsel+1,R,Men[Tsel]);
  }
  while (!Exit);
  return Sel;
}

void main()
{
	Color(WHITE,BLUE);
	char Menu[][15]={"Manage ",
		   "Transact",
		   "Passbook",
		   "Quit  "};
	char SMenu[][15]={"Create		",
			"Search		",
			"Modify		",
			"View Details",
			"Delete ",
			"Close		  "};
	int Quit=0;
  do
  { clrscr();
	//Display Main Menu1
	int N=HMenu(1,1,Menu,4),SN;
	switch (N)
	{
	case 0://Displaying Vertical Popup menu
	 SN=VMenu(1,2,SMenu,6);
	 switch(SN)
	 {
	   case 0://Call the Function for SubOption1
		  clrscr();
		  add();
		  break;
	   case 1:clrscr();
		  cout<<"Enter account number you want to search for :"<<endl;
		  int acc;
		  cin>>acc;
		  cout<<endl;
		  clrscr();
		  Account_holder a;
		  fstream f;
		  f.open("master.dat",ios::in|ios::binary);
		  int found=0;
		  while(f.read((char*)&a,sizeof(a))  &&  (!found))
		  {
			if(a.retacc()==acc)
			{a.Disp();found++;}

		  }
		  if(found==0)
		  cout<<"Required record was not found"<<endl;
		  f.close();


		  break;

	   case 2: clrscr();
		   cout<<"Enter account no. for whom you wish to modify:";




	 }
	 getch();
	 break;
	case 1:DispCh(30,10,"Option 2");break;
	case 2:DispCh(30,10,"Option 3");break;
	case 3:DispCh(30,10,"Thank u");
	 Quit=1;
	}
  }
  while (!Quit);
  getch();


}



Is This A Good Question/Topic? 1
  • +

Replies To: C++ error removal, declaration terminated incorrectly

#2 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: C++ error removal, declaration terminated incorrectly

Posted 26 October 2009 - 06:20 AM

Where in all that code did the error occur?
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6092
  • View blog
  • Posts: 23,612
  • Joined: 23-August 08

Re: C++ error removal, declaration terminated incorrectly

Posted 26 October 2009 - 06:36 AM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

#4 olibenu  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 45
  • View blog
  • Posts: 538
  • Joined: 31-December 08

Re: C++ error removal, declaration terminated incorrectly

Posted 26 October 2009 - 06:44 AM

what is the error line
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1