-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise4.cpp
More file actions
43 lines (38 loc) · 992 Bytes
/
exercise4.cpp
File metadata and controls
43 lines (38 loc) · 992 Bytes
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
#include <iostream>
using namespace std;
class House {
public:
int floorSize = 10;
int noOfFloors = 3;
int noOfDoors = 6;
void switchOn(){
cout << "Switching On..." << endl;
lightOpen();
ovenOpen();
}
void lightOpen(){
cout << "The light is open." << endl;
}
void ovenOpen(){
cout << "The oven is open." << endl;
}
};
class TownHouse: public House {
public:
int noOfFloors = 2;
int noOfDoors = 4;
};
class SmallHouse: public House {
public:
int floorSize = 5;
int noOfFloors = 1;
int noOfDoors = 3;
};
int main(){
SmallHouse myHouse;
cout << "Floor size: " << myHouse.floorSize << endl;
cout << "Number of Floors: " << myHouse.noOfFloors<< endl;
cout << "Number of Doors: " << myHouse.noOfDoors << endl;
myHouse.switchOn();
return 0;
}