Jump to content

C++ Help Urgent

ROck_

Please help,I am getting warning messages when compile : function containing while/for are not expanded inline

	# include <fstream.h>
	# include <iostream.h>
	# include <conio.h>
	# include <stdio.h>
	# include <string.h>
	# include <ctype.h>
	fstream fin;
	fstream finm;
	fstream fout;
	class Lib
       {
	int i,pos,is_book,nor_i,nor_b,f_ac;
	int rec_b,rec_i;
	char ch,ans;
	public:
	struct book
	{
		int acc_no;
		int pgs;
		float cost;
		int copies;
		char b_name[35];
		char author[35];
	}bookfile;

	struct transaction
	{
		int ac_no;
		char book_n[35];
		int dd,mm,yy;
		int chk;
	}transfile;
//-------------------------------------------------------------------------------
	int i_record()
	{
	fout.seekg(0,ios::end);
	pos=fout.tellp();
	rec_i=pos/sizeof(transaction);
	return rec_i;
	}
//------------------------------------------------------------------------------------------
	int b_record()
	{
	fin.seekg(0,ios::end);
	pos=fin.tellp();
	rec_b=pos/sizeof(book);
	return rec_b;
	}
//---------------------------------------------------------------------------------------------
void return_b()
     { int off=0,ptrt=0,ret=0;
       clrscr();
       gotoxy(20,12);cout<<"Enter the Acc. No.:";
       cin>>is_book;
       nor_i=i_record();
       while (ret<nor_i)
	     { fout.seekg(ret*(sizeof(transaction)),ios::beg);
	       fout.read((char*)&transfile,sizeof(transaction));
		nor_b=b_record();
				 while (off<nor_b)
				       { fin.seekg(off*(sizeof(book)),ios::beg);
					 fin.read((char*)&bookfile,sizeof(book));
					 if (bookfile.acc_no==is_book)
					    { ptrt = 1;
					      bookfile.copies = bookfile.copies + 1;
					      transfile.chk=0;
					      gotoxy(20,21);cout<<"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿";
					      gotoxy(20,22);cout<<"³         BOOK RETURNED        ³";
					      gotoxy(20,23);cout<<"ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ";
					      fin.seekp(off*(sizeof(book)),ios::beg);
					      fin.write((char*)& bookfile,sizeof(book));
					      fout.seekp(ret*(sizeof(transaction)),ios::beg);
					      fout.write((char*)& transfile,sizeof(transaction));
					      getch();
					      clrscr();
					      break;
					    }
					 else {off++;}
				       };
				 break;
			  };
	if (ptrt==0)
	   { gotoxy(20,21);cout<<"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿";
	     gotoxy(20,22);cout<<"³       Book No. Incorrect       ³";
	     gotoxy(20,23);cout<<"ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ";
	     getch();
	   }
     }
//---------------------------------------------------------------------------------------------
void issue()
     {int off=0,ptrb=0;
      clrscr();
     gotoxy(20,12);cout<<"ENTER THE ACC N0. :";
			cin>>is_book;
			nor_b=b_record();
			nor_i=i_record();
		    while(off<nor_b)
		    {	fin.seekg(off*(sizeof(book)),ios::beg);
			fin.read((char*)&bookfile,sizeof(book));
			if(bookfile.acc_no==is_book)
			{ 	ptrb=1;
			 if(bookfile.copies-1 < 0)
			 {	gotoxy(20,21);cout<<"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿";
				gotoxy(20,22);cout<<"³       BOOK NOT AVALIABLE     ³";
				gotoxy(20,23);cout<<"ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ";
				getch();
				break;
			 }
		       else{bookfile.copies = bookfile.copies-1;
			    gotoxy(3,9); cout<<"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»";
			    gotoxy(3,10);cout<<"º°°°°°°°°°°°°°°°°°°°°°°°°°  BOOKS  °°°°°°°°°°°°°°°°°°°°°°°º";
			    gotoxy(3,11);cout<<"ÌÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹";
			    gotoxy(3,12);cout<<"º 1.³Acc_No        ³                                      º";
			    gotoxy(3,13);cout<<"º 2.³Book Name     ³                                      º";
			    gotoxy(3,14);cout<<"º 3.³Date of Issue ³                                      º";
			    gotoxy(3,15);cout<<"º 4.³Date of Return³                                      º";
			    gotoxy(3,16);cout<<"ÈÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ";
			    gotoxy(25,12);cout<<is_book;
			    transfile.ac_no=is_book;
			    gotoxy(25,13);puts(bookfile.b_name);
			    strcpy(transfile.book_n,bookfile.b_name);
			    gotoxy(25,14);cin>>transfile.dd>>transfile.mm>>transfile.yy;
			    if(transfile.mm<12)
			    {
			     gotoxy(25,15);cout<<transfile.dd<<" "<<transfile.mm+1<<" "<<transfile.yy;
			    }
			    else
			    if(transfile.mm==12)
			    {
			     gotoxy(25,15);cout<<transfile.dd<<" 01"<<" "<<transfile.yy+1;
			    }
			    transfile.chk=1;
			    fout.seekp(nor_i*(sizeof(transaction)),ios::beg);
			    fout.write((char*)& transfile,sizeof(transaction));
			    fin.seekp(off*(sizeof(book)),ios::beg);
			    fin.write((char*)& bookfile,sizeof(book));
			    nor_i++;
			    getch() ;
			    clrscr();
			    gotoxy(20,21);cout<<"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿";
			    gotoxy(20,22);cout<<"³           BOOK ISSUED        ³";
			    gotoxy(20,23);cout<<"ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ";
			    getch();
			    clrscr();
			    break;
			   }
		      }
		     else{off++;
			 }
		   };
		   if(ptrb==0)
			{ gotoxy(20,21);cout<<"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿";
			  gotoxy(20,22);cout<<"³      BOOK DOES NOT EXIST     ³";
			  gotoxy(20,23);cout<<"ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ";
			  getch();
			}
		 }
//---------------------------------------------------------------------------------
void find_book()
    {int offset=0,ptr=0;
     clrscr();
      gotoxy(20,12);cout<<"ENTER THE ACC N0. :";
     cin>>f_ac;
     nor_b=b_record();
     while(offset<nor_b)
	  {fin.seekg(offset*(sizeof(book)),ios::beg);
	   fin.read((char*)&bookfile,sizeof(book));
	   if(bookfile.acc_no==f_ac)
	     {ptr=1;
	      gotoxy(5,5); cout<<"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»";
	      gotoxy(5,6); cout<<"º°°°°°°°°°°°°°°°°°°°°°°°°°  BOOKS  °°°°°°°°°°°°°°°°°°°°°°°º";
	      gotoxy(5,7); cout<<"ÌÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹";
	      gotoxy(5,8); cout<<"º 1.³Acc_No        ³                                      º";
	      gotoxy(5,9); cout<<"º 2.³Book Name     ³                                      º";
	      gotoxy(5,10);cout<<"º 3.³Author        ³                                      º";
	      gotoxy(5,11);cout<<"º 4.³Pages         ³                                      º";
	      gotoxy(5,12);cout<<"º 5.³Cost          ³                                      º";
	      gotoxy(5,13);cout<<"º 6.³No. of Copies ³                                      º";
	      gotoxy(5,14);cout<<"ÈÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ";
	      gotoxy(27,8);cout<<f_ac;
	      gotoxy(27,9);puts(bookfile.b_name);
	      gotoxy(27,10);puts(bookfile.author);
	      gotoxy(27,11);cout<<bookfile.pgs;
	      gotoxy(27,12);cout<<bookfile.cost;
	      gotoxy(27,13);cout<<bookfile.copies;
	      getch();
	      break;
	     }
	   else{offset++;
	       }
	  };
     if(ptr==0)
       {gotoxy(20,21);cout<<"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿";
	gotoxy(20,22);cout<<"³     BOOK DOES NOT EXIST     ³";
	gotoxy(20,23);cout<<"ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ";
	getch();
	clrscr();
       }

    }
//--------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------
void display_book()
     {clrscr();
      fin.seekg(0);
      nor_b=b_record();
      for(i=0;i<nor_b;i++)
	 { clrscr();
	   fin.seekg(i*sizeof(book),ios::beg);
	   fin.read((char*)& bookfile,sizeof(book));
	   if (bookfile.acc_no!=0)
	      { gotoxy(5,5); cout<<"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»";
		gotoxy(5,6); cout<<"º°°°°°°°°°°°°°°°°°°°°°°°°°  BOOKS  °°°°°°°°°°°°°°°°°°°°°°°º";
		gotoxy(5,7); cout<<"ÌÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹";
		gotoxy(5,8); cout<<"º 1.³Acc_No        ³                                      º";
		gotoxy(5,9); cout<<"º 2.³Book Name     ³                                      º";
		gotoxy(5,10);cout<<"º 3.³Author        ³                                      º";
		gotoxy(5,11);cout<<"º 4.³Pages         ³                                      º";
		gotoxy(5,12);cout<<"º 5.³Cost          ³                                      º";
		gotoxy(5,13);cout<<"º 6.³No. of Copies ³                                      º";
		gotoxy(5,14);cout<<"ÈÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ";
		gotoxy(27,8);cout<<i+1;
		gotoxy(27,9);puts(bookfile.b_name);
		gotoxy(27,10);puts(bookfile.author);
		gotoxy(27,11);cout<<bookfile.pgs;
		gotoxy(27,12);cout<<bookfile.cost;
		gotoxy(27,13);cout<<bookfile.copies;
		getch();
	      }
	 }
     }
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
void main_book()
     {nor_b=b_record();
      do{ gotoxy(3,5); cout<<"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»";
	  gotoxy(3,6); cout<<"º°°°°°°°°°°°°°°°°°°°°° ENTRY FOR BOOKS °°°°°°°°°°°°°°°°°°°º";
	  gotoxy(3,7); cout<<"ÌÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹";
	  gotoxy(3,8); cout<<"º 1.³Acc_No        ³                                      º";
	  gotoxy(3,9); cout<<"º 2.³Book Name     ³                                      º";
	  gotoxy(3,10);cout<<"º 3.³Author        ³                                      º";
	  gotoxy(3,11);cout<<"º 4.³Pages         ³                                      º";
	  gotoxy(3,12);cout<<"º 5.³Cost          ³                                      º";
	  gotoxy(3,13);cout<<"º 6.³No. of Copies ³                                      º";
	  gotoxy(3,14);cout<<"ÈÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ";
	  bookfile.acc_no=nor_b+1;
	  gotoxy(25,8);cout<<nor_b+1;
	  gotoxy(25,9);gets(bookfile.b_name);
	  gotoxy(25,10);gets(bookfile.author);
	  gotoxy(25,11);cin>>bookfile.pgs;
	  gotoxy(25,12);cin>>bookfile.cost;
	  gotoxy(25,13);cin>>bookfile.copies;
	  fin.seekp(nor_b*(sizeof(book)),ios::beg);
	  fin.write((char*)& bookfile,sizeof(book));
	  nor_b++;
	  clrscr();
	  gotoxy(20,12);cout<<"DO YOU WANNA CONTINUE [y/n].... ";
	  cin>>ans;
       }while (ans=='y' || ans=='Y');
     }
 };
//----------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
void main()
    {int ch;
    Lib l;
     clrscr();
     fin.open ("BOOKMAST.DAT",ios::in|ios::out|ios::binary);
     fout.open("BOOKTRNS.DAT",ios::in|ios::out|ios::binary);
     do{clrscr();
	gotoxy(25,5); cout<<"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»";
	gotoxy(25,6); cout<<"º     MAIN MENU     º";
	gotoxy(25,7); cout<<"ÌÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹";
	gotoxy(25,8); cout<<"º 1.³Display Books  º";
	gotoxy(25,9); cout<<"º 2.³Add New Books  º";
	gotoxy(25,10);cout<<"º 3.³Issue          º";
	gotoxy(25,11);cout<<"º 4.³Return         º";
	gotoxy(25,12);cout<<"º 5.³Find a Book    º";
	gotoxy(25,13);cout<<"º 0.³Quit           º";
	gotoxy(25,14);cout<<"ÈÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ";
	gotoxy(25,20);cout<<"YOUR CHOICE.........:";
	cin>>ch;
	clrscr();
	switch (ch)
	       {case 1 : l.display_book();
			 break;
		case 2 : l.main_book();
			 break;
		case 3 : l.issue();
			 break;
		case 4 : l.return_b();
			 break;
		case 5 : l.find_book();
			 break;
		case 0 : break;
	       default : {clrscr();
			  gotoxy(20,11);cout<<"WRONG CHOICE";
			 }
	       }
       } while(ch!=0);
   fin.close();
   finm.close();
   fout.close();
  }

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Normally, one declares a class's structure in a header file and implement the actual member functions seperately outside the class, in a matching .cpp code file for example.

 

When you write the full member functions implementation inside the class then the functions are automatically inlined.  ( https://en.wikipedia.org/wiki/Inline_function )

 

The compiler is warning you that because one or more of your member functions includes a "while" or "for" it cannot make them inline and in stead makes them normal functions.

 

The solution of choice to remove the errors is to place the member functions in their own seperate code file.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×