hi!!
i,ve written d
program on airline reservation ....
but i m facing problems regarding the value of seats ... that is how do i sore different values of seats available in diff flights

class air
{
protected:
int z;
char clas[10];
char source[5][10];
char dest[5][10];
int seats;
int l;
public:
void getdata()  ;
int search(char c[10],char[10] );
void refresh();
};
void air::getdata()
{
cout<<"WELCOME TO SAHARA AIRLINES";
cout<<"LIST OF SOURCES AND DESTINATION ARE>>>>";
for(int s=0;s<2;s++)
{
cin>>source[s];
 for(int d=0;d<5;d++)
 {
 cin>>dest[d];
 cin>>seats;
 }
  cout<<endl;
 }
 }
 
 int air::search(char c[10],char b[10])
{
for(int p=0;p<5;p++)
{
if((strcmp(source[p],c)==0))
{
for(int h=0;h<5;h++)
{
if((strcmp(dest[h],b)==0))
{
cout<<"flight exists";
 cout<<"enter class"<<endl;
cin>>clas;
cout<<"SEATS>>>>";
cout<<seats;
z=seats;
return (1);
}
else
{
  l=1;
 }
 }
 }
 else
 {
l=1;
 }
 }
 if(l==1)
 {
 cout<<"sorry no flight exists as per request";
 }
}
 
void air::refresh()
{
seats=z;
}

the main function is

void main()
 {
 clrscr();
 air a;
 char k;
 char c[10];
 char b[10];
 fare f;
  fstream n;
 n.open("c:/s/pooja.txt",ios::in|ios::out|ios::ate|ios::binary|ios::trunc);
 a.getdata();
  n.write((char*)&a,sizeof(a));
 fstream z;
 z.open("c:/s/poo.txt",ios::in|ios::out|ios::ate|ios::binary|ios::trunc);
 n.seekg(0,ios::beg);
 n.read((char*)&a,sizeof(a));
 while(n)
 {
  cout<<"PLEASE ENTER UR CHOICE OF SOURCE AND DESTINATION";
 cin>>c>>b;
 n.read((char*)&a,sizeof(a));
  if( a.search(c,b)==1)
 {
 f.gets();
 f.amt();
 }
 else
 {
 exit(0);
 }
 }
 n.close();
  n.open("c:/s/pooja.txt",ios::in|ios::out|ios::ate|ios::binary|ios::trunc);
  a.refresh();
   n.write((char*)&a,sizeof(a));
 getch();
 }

and also in this particular class which is multi level inherited from d class air:

class tickets:public pass
{
protected:
int j;
char ch;
public:
void seatings();
};
void tickets::seatings()
{
if(z>0)
{
for(j=0;j<b;j++)
{
z--;
cout<<"ur this seat is available for booking"<<endl;
}
cout<<"CONFIRMATION FOR TICKRETS"<<endl;
cout<<"press 'y' to book" ;
cin>>ch;
if(ch=='y')
{
cout<<"ur"<<j<<"tickets r booked "<<endl<<"thank u ";
}
else
for(int k=j;k>0;k--)
{
z++;
}
}
}

the value of z is not passed ??
please help...

your class declarations are terrible! One-letter variable names is highly discouraged because they mean nothing to anyone except the original author, then he will forget what they mean after a couple days.

I'd suggest starting by rewriting the classes to use more descriptive variable names. As for variable z? I have no clue because I haven't the slightest idea what that variable is used for.

I think due to faulty design you are facing the problem of different seat allocation. YOur class "air" is an abstraction of the airline company but there is no facility for accomodating multiple flights and hence you have to create different instances of "air" for different flights.

Create a new class named "Flight" which would have the data members of "air" and keep a "vector" of "Flight" in your air class so that for a single instance of the "air" class for eg. Sahara, you can have different flights as well as different seats for them.

And i dont get the last part of your question? Z is not passed ?
Please elaborate on the problems and then it would be easy for us to help you.

thnx..
but now on creating the object of class "flight " in class "air" i get an error as "too many types in declaration"...
this is what i have done..

class air
{
protected:
int z;
char clas;
char source[5][10];
char dest[5][10];
int seats;
int l;
public:
 flight  f;
void getdata()  ;
int search(char c[10],char[10] );
void refresh();
};
void air::getdata()
{
cout<<setw(-10)<<"                WELCOME TO SAHARA AIRLINES"<<endl<<endl<<endl;
cout<<setw(7)<< "          LIST OF SOURCES AND DESTINATION AVAILABLE ARE>>>>";
cout<<endl;
for(int s=0;s<2;s++)
{
cout<<"      FROM   :    "<<endl<<endl;
cin>>  source[s];
 for(int d=0;d<5;d++)
 {
 cout<<"          TO : "<<endl<<endl;
 cin>>dest[d];
 cin>>seats;
 }
  cout<<endl;
 }
 }

 int air::search(char c[10],char b[10])
{
for(int p=0;p<5;p++)
{
if((strcmp(source[p],c)==0))
{
for(int h=0;h<5;h++)
{
if((strcmp(dest[h],b)==0))
{
cout<<"  YES! FLIGHT EXISTS ON THIS ROUTE      ";
 cout<<endl<<endl<<" PLEASE ENTER THE CLASS U WANNA TRAVEL BY....";
 cout<<endl;
 cout<<"PLEASE PRESS 'e' FOR CLASS ECONOMICAL>><<PRESS 'b' FOR CLASS BUSNESS>><<AND 'f' FOR THE FIRST CLASS"<<endl;
cin>>clas;
cout<<"SEATS>>>>";
cout<<seats;
z=seats;
//if(z>0)
//{
return (1);
//}
}
else
{
  l=1;
 }
 }
 }
 else
 {
l=1;
 }
 }
 if(l==1)
 {
 cout<<" WE ARE SORRY!!"<<endl<<"NO FLIGHT AVAILABLE AS PER REQUEST"<<endl<<"THANK U !!";
 ;
 }
}

please help
and the other part of the question was that in d class "air"
i had stored the value of seats in a variable 'z' now in the class "tickets" the value of this 'z' is not accessed ie; a garbage value is taken;

void tickets::seatings()
{
if(z>0)
{
for(j=0;j<b;j++)
{
z--;
cout<<"ur " <<(j+1)<<"TH"<< "  seat is available for booking"<<endl;
}
cout<<"         CONFIRMATION FOR TICKETS      "<<endl;
cout<<"PRESS  'y'  @ FINALISE UR BOOKINGS   " <<endl;
cin>>ch;
if(ch=='y')
{
cout<<"UR "<<j<<"TICKETS R BOOKED"<<endl<<"  THANK YOU  ";
}
else
for(int k=j;k>0;k--)
{
cout<<"   SORRY !!! ";
z++;
}
}
}

please reply soon...

thanks dudes!!!!!! these proved helpful for completing my project

we are also working on the same project for our class assignment. it will be really helpful if anyone can send the entire source code for reference again pls. and its urgent. so asap!

commented: I sent it, didn't you get it? lol -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.