0% found this document useful (0 votes)
35 views2 pages

Single Inheritance

The document contains a C++ program that implements single inheritance in an airline travel management system. It defines a base class for seat type booking and a derived class for seat position selection, allowing users to choose between economy and business seats, as well as different seat positions. The program prompts the user for their choices and displays the selected options.

Uploaded by

karthikeyanb2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

Single Inheritance

The document contains a C++ program that implements single inheritance in an airline travel management system. It defines a base class for seat type booking and a derived class for seat position selection, allowing users to choose between economy and business seats, as well as different seat positions. The program prompts the user for their choices and displays the selected options.

Uploaded by

karthikeyanb2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include<iostream>

#include<string>
using namespace std;

//Defining Base Class


class seat_type_booking{

public:
string seat_type;
int seat_type_choice;

//Defining a Constructor
seat_type_booking(){
cout<<"Enter your choice:";
cin>>seat_type_choice;
find_seat_type(seat_type_choice);
cout<<"You have selected "<<seat_type<<"\n";
}

//Defining A Method Function


void find_seat_type(int a){
seat_type=(seat_type_choice==1?"Economy":"Business");
}
};

//Defining Derived CLass


class seat_position_selection:public seat_type_booking{

public:
string seat_position;
int seat_position_choice;

seat_position_selection(){
cout<<"1. Window\n2. Corner\n3. Middle\n";
cout<<"Enter your choice:";
cin>>seat_position_choice;
find_seat_position(seat_position_choice);
cout<<"You have successfully choosen "<<seat_position<<"seat\n";
}

void find_seat_position(int seat_position_choice){

if(seat_position_choice==1){
seat_position="Window";
}
else if(seat_position_choice==2){
seat_position="Corner";
}
else{
seat_position="Middle";
}
}
};

int main(){

cout<<"\nImplementation Of Single Inheritance In Airline Travel Management\n";


cout<<"1. Economy\n2. Business\n";
seat_position_selection();
return 0;
}

You might also like