-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultilevelinheritance.cpp
More file actions
76 lines (66 loc) · 1.37 KB
/
multilevelinheritance.cpp
File metadata and controls
76 lines (66 loc) · 1.37 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
#include<iostream>
using namespace std;
class mall //base class
{
protected:
int rice;
int flour;
public:
void inputdata()
{
cout << "Enter amount of rice in kgs : ";
cin >> rice;
cout << "Enter amount of flour in kgs : ";
cin >> flour;
}
};
class shop:public mall
{
protected:
int chocolate;
int chips;
int coke;
public:
void getdata()
{
cout << "\nEnter number of chocolates purchased :";
cin >> chocolate;
cout << "Enter number of chips purchased : ";
cin >> chips;
cout << "Enter number of coke purchased : ";
cin >> coke;
}
};
class home:public shop
{
private:
int milk;
int sugar;
public:
void get()
{
cout << "\nEnter amount of milk in ltrs : ";
cin >> milk;
cout << "Enter amount of sugar in kgs : ";
cin >> sugar;
}
void display()
{
cout << "\nRice = " << rice << " kgs" << endl;
cout << "Flour = " << flour << " kgs" << endl;
cout << "Chocolates = " << chocolate << " box" << endl;
cout << "Chips = " << chips << " packets" << endl;
cout << "Coke = " << coke << " cans" << endl;
cout << "Milk = " << milk << " ltrs" << endl;
cout << "Sugar = " << sugar << " kgs" << endl;
}
};
int main()
{
home items;
items.inputdata();
items.getdata();
items.get();
items.display();
return 0;
}