error with my array

#include<iostream>
#include<string>
#include<iomanip>
#include<cstdlib>
using namespace std;

const int max=20;

class passenger
{

protected:
char name[60];
char address[60];
//int num_passenger;
char c_loc[30];
char dest[30];


public:

void getdata()
{
cin.ignore();
cout<<"Enter the name of passenger: ";
cin.getline(name,60);
cout<<endl<<endl;

cout<<"Enter address of passenger: ";
cin.getline(address,60);
cout<<endl<<endl;

cout<<"Enter the current location of passenger: ";
cin.getline(c_loc,60);
cout<<endl<<endl;

cout<<"Enter the destination of passenger: ";
cin.getline(dest,60);
cout<<endl<<endl;


}


void show()
{
cout<<"Passenger name is:"<<setw(4)<<name<<endl;
cout<<"Address of passenger is:"<<setw(4)<<address<<endl;
cout<<"Current location of passenger is:"<<setw(4)<<c_loc<<endl;
cout<<"Destination of passenger is:"<<setw(4)<<dest<<endl;
cout<<endl<<endl;
}


};

class booking:public passenger
{
protected:
int num;

public:

void getdata()
{
cout<<"How many bookings you want to make?"<<endl;
cin>>num;

for(int i=0;i<num;i++)
{
cout<<"Please enter the required information for passenger number:"<<i+1<<endl;
passenger::getdata();
system("CLS");
}
}
void show()
{
for(int j=0;j<num;j++)
{
cout<<"Following is some information about passenger number:"<<j+1<<endl;
passenger::show();
}
}

};

class search
{
protected:
int t;

public:



void searching()
{
char l_destination[5][max]={"LAHORE","ISLAMABAD","KARACHI","PESHAWAR","QUETTA"};
char i_destination[10][max]={"LONDON","BERLIN","DUBAI","NEW YORK","BEIJING","PARIS","CAPE TOWN","TOKYO","LOS ANGELES","MUMBAI" };

t=0;
cout<<setw(10)<<"FOLLOWING ARE THE INTERNATIONAL FLIGHTS AVAILABLE"<<endl;
for(int i=0;i<5;i++)
{
t++;
for(int j=0;j<10;j++)
{
cout<<"FLIGHT FROM "<<l_destination[i]<<" TO "<<i_destination[j]<<" IS AT "<<t+1<<"00 HRS"<<endl;
t++;
}
}

cout<<setw(10)<<"FOLLOWING ARE THE LOCAL FLIGHTS AVAILABLE"<<endl;

for(int x=0;x<5;x++)
{
t++;
for(int y=0;y<4;y++)
{

cout<<"FLIGHT FROM "<<l_destination[x]<<" TO "<<l_destination[y+1]<<" IS AT:"<<t<<"00 HRS"<<endl;
t+2;
cout<<"FLIGHT FROM "<<l_destination[y+1]<<" TO "<<l_destination[x]<<" IS AT:"<<t<<"00 HRS"<<endl;
}
}
}
friend class local;
friend class international;
};

class local:public booking
{
protected:
int b_seat;
int e_seat;
int ch;

public:

void travel(search s)
{
cout<<"THESE ARE THE LOCAL PLACES AVAILABLE"<<endl;
for(int i=0;i<4;i++)
{
cout<<s.l_destination[i]<<endl;////////////////////////////////////////////////////////here is the error
}
booking::getdata();
for(int j=0;j<4;j++)
{
if(strcmp(s.l_destination[j],dest)==0 &&strcmp(s.l_destination[j],c_loc)==0)
cout<<"FLIGHT AVAILABLE ON THIS ROUTE";
}

b_seat=30;
e_seat=40;
cout<<setw(20)<<"In which class you want to travel? Make your choice"<<endl<<endl;
cout<<"Press 1 for buisness class"<<endl;
cout<<"Press 2 for economy class"<<endl;
cout<<"Enter your choice"<<endl;
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
b_seat--;
if(b_seat<=0)
cout<<"SORRY NO SEAT AVAILABLE"<<endl;
else
cout<<"SEAT AVAILABLE"<<endl;
break;
case 2:
e_seat--;
if(e_seat<=0)
cout<<"SORRY NO SEAT AVAILABLE"<<endl;
else
cout<<"SEAT AVAILABLE"<<endl;
break;
}
}


void show()
{
booking::show();
if(ch==1)
{
cout<<"YOUR TRAVELLING CLASS IS BUISNESS"<<endl;
}
if(ch==2)
{
cout<<"YOUR TRAVELLING CLASS IS ECONOMY"<<endl;
}

cout<<"YOUR TICKETS ARE BOOKED"<<endl;
}

};






void main()
{
passenger p1;
booking b1;
search s1;
local l1;
l1.travel(s1);
s1.searching();
}







error with my l_destination array cant access values of it
Last edited on
That makes sense: l_destination exists only in the searching() function -- it is not a class.
Topic archived. No new replies allowed.