#include<iostream.h>
#include <stdlib.h> //FOR exit(1)

  struct Flight
  {
  char flightNo[5];
  char date[12];
  char time[6];
  char gate[3];
  };

  Flight flight={"AB11","10-12-2008","20:30","RT"};

  struct Seat
  {
  char name[40];
  char booking_ID[3];
  int seats;
  };

  Seat choice[4][5];

  void displaymenu();
  void booking();
  void seat();
  void ticket();
  void records();

  void menu();
  void exit();

 //Variables
 int selection,i,j,password;
 int seats_num[20]={0};
 int booking_ID=100;
 int seatsAvailable=20;

 int main(void)
 {
 displaymenu();
 while(selection!=4)
 {
 menu();
 }
 return 0;
 }

 void displaymenu()
 {

 cout<<"\n\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
 cout<<"\n\t%                                    %\n";
 cout<<"\t%   Airline Booking System           %\n";
 cout<<"\t%    =======================         %\n";
 cout<<"\t%         MENU                       %\n";
 cout<<"\t%    =======================         %\n";
 cout<<"\t%      1.BOOKING                     %\n";
 cout<<"\t%      2.SEAT                        %\n";
 cout<<"\t%      3.RECORDS                     %\n";
 cout<<"\t%      4.EXIT                        %\n";
 cout<<"\t%                                    %\n";
 cout<<"\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\t";

 cout<<"\t\nEnter your selection :";
 cin>>selection;
 menu();
 }

 //looping()
 void menu()
 {
 switch(selection)
 {
 case 1:
 booking();
 break;
 case 2:
 seat();
 break;
 case 3:
 records();
 break;
 case 4:
 exit();
 break;
 default:
 cout<<"\tInvalid selecion.Try again\n";
 }
 }

 //booking
 void booking()
 {
   for(i=0;i<4;i++)
     for(j=0;j<5;j++)
     {
       cout<<"Please enter number of seats that you want to reserve : ";
      cin>>choice[i][j].seats;


          if(choice[i][j].seats<=seatsAvailable)
          {
              cout<<"Please enter passenger name : ";
              cin>>choice[i][j].name;

               ticket();
              booking_ID++;

          }
         seatsAvailable=seatsAvailable-choice[i][j].seats;


         if((choice[i][j].seats>=seatsAvailable) ||(choice[i][j].seats<=seatsAvailable))
          {
         cout<<"\n";
         cout<<"\tThe flight leave  seats="<<seatsAvailable;
         displaymenu();
          }
        if(seatsAvailable<=0)
        {
           cout<<"\n";
         cout<<"\t the flight is fully booked\n";
         cout<<"\t=================END=================\n\n";
         displaymenu();

        }
         displaymenu(); 

     }   
 }

 void ticket()
 {
    int i=0;
    int j=0;
  cout<<"\n\n";

  cout<<"\t-----------------AIRLINE BOOKING TICKET----------------\n";
  cout<<"\n++++++++++============================================================++++++++++\n";
  cout<<" Booking ID:\tFlight No :\tPassenger:\tDate:\tTime:\tGate:\tSeats No\n";
  cout<<"\t"<<booking_ID<<"\t"<<flight.flightNo<<"\t\t";
  cout<<choice[i][j].name;
  cout<<"\t   "<<flight.date<<"\t"<<flight.time<<"\t"<<flight.gate;
  cout<<"\t"<<i+1<<j+65;
  cout<<"\n++++++++++============================================================++++++++++\n";
 }


 //seat
 void seat()
 {
   cout<<" A B C D E\n";
      for(j=0;j<5;j++)
      {
        cout<<booking_ID;
      }
        for(i=0;i<4;i++)
        {
          cout<<"\n";
         cout<<"\n"<<i+1;
        }

    displaymenu();
 }

 void records() //For Staff to View the flight's records
 {
    cout<<"\t\nPlease enter password: ";
     cin>>password; //111

      if (password==111)
      {

      cout<<"\t====================================\n";
      cout<<"\tALL FLIGHT RECORDS\n";
      cout<<"\t====================================\n";
      cout<<"\tSeats Available left :"<<seatsAvailable;     
      ticket();
      displaymenu();

      }
     else
     {
     cout<<"\tInvalid password\n\n";
      displaymenu();
     }

 }

 void exit()
 {
     cout<<"\tThank you for using this system\n";
     exit(1);
 } }

I mean to say that i want to bring a little bit changes in my code,by introducing CLASSES rather than using the structures. suggestions plz...that at which points i have to bring the changes.

In c++ a struct is nearly identical to a class. Just rename the struct to class and make members public

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.