-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiamondShape.py
33 lines (27 loc) · 883 Bytes
/
DiamondShape.py
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
"""
Diamond Shape Problem is an ambiguity. It happens when we are doing
multiple inheritance. Grand child class face a confusion if there is a function
or an attribute which is present in its all parent class or the root class
then the function or an attribute from which class will be used.
Python syntax can solve this problem but this is a problem for other
languages like C++. So we should avoid this other wise your C++ compiler
will get confuse and there will be an error.
"""
class A:
def thisclass(self):
print("This function is from class A.")
class B(A):
def thisclass(self):
print("This function is from class B.")
class C(A):
def thisclass(self):
print("This function is from class C.")
class D(C, B):
def thisclass(self):
print("This function is from class D.")
pass
a = A()
b = B()
c = C()
d = D()
d.thisclass()