-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheiraricalinheritance.cpp
More file actions
81 lines (75 loc) · 1.43 KB
/
Copy pathheiraricalinheritance.cpp
File metadata and controls
81 lines (75 loc) · 1.43 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
#include<iostream>
using namespace std;
class mobile
{
protected:
char color[10];
int price;
char os[10];
public:
void input()
{
cout << "\nColor of Mobile : ";
cin >> color;
cout << "Price of Mobile : ";
cin >> price;
cout << "Operating System of Mobile : ";
cin >> os;
}
};
class iphone:public mobile
{
private:
char imodel[20];
int ios;
public:
void get1()
{
cout << "Latest Model : ";
cin >> imodel;
cout << "IOS version of Mobile : ";
cin >> ios;
}
void show1()
{
cout << "\nColor = " << color << endl;
cout << "Price = " << price << endl;
cout << "Operating System = " << os << endl;
cout << "Latest iphone Model = " << imodel << endl;
cout << "IOS version of Mobile = " << ios << endl;
}
};
class samsung:public mobile
{
private:
char smodel[20];
int android;
public:
void get2()
{
cout << "Latest Model : ";
cin >> smodel;
cout << "Android version of Mobile : ";
cin >> android;
}
void show2()
{
cout << "\nColor = " << color << endl;
cout << "Price = " << price << endl;
cout << "Operating System = " << os << endl;
cout << "Latest Samsung Model = " << smodel << endl;
cout << "Android version = " << android << endl;
}
};
int main()
{
iphone i;
i.input();
i.get1();
i.show1();
samsung s;
s.input();
s.get2();
s.show2();
return 0;
}