-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut43.cpp
More file actions
62 lines (52 loc) · 921 Bytes
/
tut43.cpp
File metadata and controls
62 lines (52 loc) · 921 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<iostream>
using namespace std;
class Base1{
public:
void greet(){
cout<<"How are you?"<<endl;
}
};
class Base2{
public:
void greet()
{
cout << "Kaise ho?" << endl;
}
};
class Derived : public Base1, public Base2{
int a;
public:
void greet(){
Base2 :: greet();
}
};
class B{
public:
void say(){
cout<<"Hello world"<<endl;
}
};
class D: public B{
int a;
// D's new say() method will override base class's say() method
public:
void say()
{
cout << "Hello my beautiful people" << endl;
}
};
int main(){
// Ambibuity 1
// Base1 base1obj;
// Base2 base2obj;
// base1obj.greet();
// base2obj.greet();
// Derived d;
// d.greet();
// Ambibuity 2
B b;
b.say();
D d;
d.say();
return 0;
}