Dear all, I would like to ask you how to initialize the following:
I want to initialize a class inside another class.
How I will be able to do so?
An example:
/*Class Date*/
class Date {
public:
Date(){} // default constructor
int day;//day of the month valid till 31
int month; //month of the year , valid till the 12
int year;//year
/* function prototypes*/
void setDate(int d, int m, int y);
void printDate();
};
/*functions*/
void Date::setDate(int d, int m, int y){day=d;month=m;year=y;}// i must vallidate entries for days months etc
void Date::printDate(){cout <<day<< "/" << month << "/" << year <<endl;}
/*end class Date*/
This is the class I want to include in another class implementation
I want to include this in the following class:
/*Class Flights*/
class Flights{
public:
Flights(){}
string flight_code;
string departure;
string destination;
FlightOperators FOperator;
int seats; // avaliable seats based on the flight
int meals; // available meals
int drinks; //available drinks in the flight
Date departuredate; //departure date of type class Date
Time departuretime; // departure time of type class Time
//functions
void addFlights(string FC, string Dp,string Ds, int s,int dd);
void getFlights();
void searchFlights();
void updateFlights();
};
void Flights::addFlights(string FC, string Dp,string Ds, int s,int dd){flight_code=FC;departure=Dp;destination=Ds;}
void Flights::getFlights(){cout<<"Get flights"<<endl;}
void Flights::searchFlights(){cout<<"Search flights"<<endl;}
void Flights::updateFlights(){cout<<"Updateflights"<<endl;}
/*end Class Flights*/
I will create a member function inside flights?
how I am going to implement this???
I also have another function to initialize 150 array objects of class flights
Flights *FL=new Flights[150];
FL[0] ....??????
Thanks