-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultipleinheritance2.cpp
More file actions
104 lines (93 loc) · 2.34 KB
/
multipleinheritance2.cpp
File metadata and controls
104 lines (93 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include<iostream>
using namespace std;
class car //base class
{
protected:
int color;
char fuel;
public:
void inputdata()
{
cout << "Enter color of your car :" << endl;
cout << "1. Silver \n2. Golden \n3. Black" << endl;
cin >> color;
cout << "Enter fuel type of your car : ";
cin >> fuel;
}
// void showdata()
// {
// if(color==1)
// cout << "Color of your car is Silver" << endl;
// else if(color==2)
// cout << "Color of your car is Golden" << endl;
// else if(color==3)
// cout << "Color of your car is Black" << endl;
// else
// cout << "This Color Code doesn't exist" << endl;
//
// cout << "Fuel of your car is " << fuel;
// }
};
class sportscar
{
protected:
int maxspeed;
int alarm;
int airbags;
public:
void getdata()
{
cout << "\nEnter Maximum Speed of your car :" << endl;
cin >> maxspeed;
cout << "Enter number of Alarms in your car : " << endl;
cin >> alarm;
cout << "Enter number of Air Bags in your car : " << endl;
cin >> airbags;
}
// void setdata()
// {
// cout << "Maximum Speed of your car : " << maxspeed << endl;
// cout << "Alarms in your car : " << alarm << endl;
// cout << "Air Bags in your car : " << airbags << endl;
// }
};
class luxurycar:public car,public sportscar
{
private:
int sunroof;
int LEDs;
public:
void get()
{
cout << "\nEnter Sun roofs in your car :" << endl;
cin >> sunroof;
cout << "Enter number of LEDs in your car : " << endl;
cin >> LEDs;
}
void display()
{
if(color==1)
cout << "Color of your car is Silver" << endl;
else if(color==2)
cout << "Color of your car is Golden" << endl;
else if(color==3)
cout << "Color of your car is Black" << endl;
else
cout << "This Color Code doesn't exist" << endl;
cout << "Fuel of your car is " << fuel << endl;
cout << "Maximum Speed of your car : " << maxspeed << endl;
cout << "Alarms in your car : " << alarm << endl;
cout << "Air Bags in your car : " << airbags << endl;
cout << "Sun roofs in your car : " << sunroof << endl;
cout << "LEDs in your car : " << LEDs << endl;
}
};
int main()
{
luxurycar maybach;
maybach.inputdata();
maybach.getdata();
maybach.get();
maybach.display();
return 0;
}