-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultipleInheritance.cpp
More file actions
136 lines (123 loc) · 3.23 KB
/
Copy pathMultipleInheritance.cpp
File metadata and controls
136 lines (123 loc) · 3.23 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Multiple Inheritance
#include<iostream>
#include<math.h>
using namespace std;
class A
{
protected:
int a, b, c;
public:
void get()
{
cout<<"Enter the value of a, b : ";
cin>>a>> b;
c = a+b;
}
};
class B
{ protected:
int s;
public:
void sumOfSquare()
{
int a = 10, b = 20;
s = pow(a,2) + pow(b,3);
}
};
class C:public A, public B
{
public:
void SumOfCube()
{
int d;
d = pow(a,3) + pow(b,3);
cout<<"Sum of Cubes : "<<d<<endl;
cout<<"Added Value are : "<<c<<endl;
cout<<"Sum of square : "<<s<<endl;
}
};
//Parant Class
class Car
{
protected:
int color_code;
char Fuel_type[10];
public:
void inputdata()
{
cout<<"Color of car as \n 1. Silver \n 2. White \n 3. Black \n Enter the Color of your car => ";
cin>>color_code;
cout<<"Enter your car fuel type => ";
cin>>Fuel_type;
cout<<"---------------*************************------------------------"<<endl;
}
};
class SportsCar
{
protected:
int max_speed;
int alarm;
int airbags;
public:
void getdata()
{
cout<<"Enter the maximum speed of your car => ";
cin>>max_speed;
cout<<"Enter the number of alarm in your car => ";
cin>>alarm;
cout<<"Enter the number of airbags in your car => ";
cin>>airbags;
cout<<"---------------*************************------------------------"<<endl;
}
};
class luxurycar:public Car, public SportsCar
{
private:
int sunroof;
int qled;
public:
void data()
{
cout<<"Enter the number of sunroof : ";
cin>>sunroof;
cout<<"Enter the number of qled : ";
cin>>qled;
cout<<"---------------*************************------------------------"<<endl;
}
void viewdata()
{
if(color_code == 1)
{
cout<<"Color of your car is Silver "<<endl;
}
else if(color_code == 2)
{
cout<<"Color of your car is White "<<endl;
}
else if(color_code == 3)
{
cout<<"Color of your car is Black "<<endl;
}
cout<<"Fuel type of your car is "<<Fuel_type<<endl;
cout<<"Maximum speed of your car => "<<max_speed<<endl;
cout<<"Number of alarm in your car => "<<alarm<<endl;
cout<<"Number of airbags in your car => "<<airbags<<endl;
cout<<"Number of sunroof in your car => "<<sunroof<<endl;
cout<<"Number of qled in your car => "<<qled<<endl;
cout<<"---------------*************************------------------------"<<endl;
}
};
int main()
{
C obj;
obj.get();
obj.sumOfSquare();
obj.SumOfCube();
cout<<"****************************************"<<endl;
luxurycar rollroyce;
rollroyce.inputdata();
rollroyce.getdata();
rollroyce.data();
rollroyce.viewdata();
return 0;
}