to perform multilevel inhertiance what should be our structure (or how to implement multilevel inheritance)
To perform multilevel inhertiance what should be our structure (or how to implement multilevel inheritance)
hey @tanujvats0002_111433f919bfdb0c ,
Yes you can perform multi level inheritance in python .
One way is to directly give names of all those classes directly while creating the sub class
like this
class AB( ABD, CBF , A , B … , M ):
else
in sequential manner.
A - > B -> C- >D …
class A: pass
class B(a) : pass
class C(B): pass
In this way.
I hope this helps.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
Multi-Level and Multiple Inheritance
The key difference between Multiple and Multilevel Inheritance is that Multiple Inheritance is when a class inherits from many base classes while Multilevel Inheritance is when a class inherits from a derived class making that derived class a base class for a new class.
Allowing multiple inheritance makes the rules about function overloads and virtual dispatch decidedly more tricky, as well as the language implementation around object layouts. These impact language designers/implementors quite a bit, and raise the already high bar to get a language done, stable and adopted.
It is simple to think this way, if class A inherits from multiple classes, then the class A will have the same grandparent class multiple times, this means the code will be complicated and a series of bugs will go unacknowledged. Personally, I think multiple inheritance has a bad rap, and that a well done system of trait style composition would be really powerful/useful… but there are a lot of ways that it can be implemented badly, and a lot of reasons it’s not a good idea in a language like C++.