#include<iostream.h>
#include<conio.h>
class vehicle
{
protected:
char regno[10];
int model;
public:
void read()
{
cout<<"\nEnter the Register Number:";
cin>>regno;
cout<<"\nEnter the model number:";
cin>>model;
}
};
class fourwheeler : public vehicle
{
protected:
int no_cylinder;
public:
void read1()
{
read();
cout<<"\nEnter the no.of cylinder";
cin>>no_cylinder;
}
};
class car : public fourwheeler
{
protected:
char name[10],owner[20];
int no_seats;
float price1;
public:
void read2()
{
read1();
cout<<"\nEnter the name,owner ,no_seats and price:\n";
cin>>name>>owner>>no_seats>>price1;
}
};
class ac
{
protected:
float capacity;
char make[20];
float price2;
public:
void read3()
{
cout<<"\nEnter the capacity,maker,price2:";
cin>>capacity>>make>>price2;
}
};
class ac_car : public car,public ac
{
protected:
float total_price;
float fitting_charge;
public:
ac_car()
{
fitting_charge=1000.0;
}
void read4()
{
read2();
read3();
total_price=price1+price2;
}
void print()
{
cout<<"\nRegno:"<<regno;
cout<<"\nModel:"<<model;
cout<<"\nNo-cylinder:"<<no_cylinder;
cout<<"\nName:"<<name;
cout<<"\nOwner:"<<owner;
cout<<"\nNo-of-seats:"<<no_seats;
cout<<"\nTotal Price(including fitting charges):"<<total_price+fitting_charge;
}
};
void main()
{
ac_car a1;
clrscr();
cout<<"\n\t\t HYBRID INHERITANCE\n";
a1.read4();
a1.print();
getch();
}
Comments
Post a Comment