When will you use multiple inheritance and when will you use multi level inheritance Describe with an example? |
[Edit] |
Just take the following book from the library:"Effective C++" by Scott Meyers. He has a whole chapter about pros and cons of Multiple Inheritance and why and when you should and SHOULD NOT use it. Also, the ultimate guide is : "The C++ Programming Language" by B.Stroustrup, the father of C++.
Cheers, Dragomir Stanchev
When asked in an interview or otherwise a brief answer is:
"Multiple Inheritance is when a derived class inherits properties and methods from multiple classes as opposed to Single Inheritance. So, for cases where I find that I have two or more classes and another new class is to be created that has properties and behaviour of both or all the base classes then I use Multiple inheritance. For example, If base class one is Terrestrial and Base Class two is Aquatic, then the new class Amphibian will be case of multiple inheritance deriving from both the two base classes."
First answer by ID1402035698. Last edit by Abhijeetsinha. Contributor trust: 14 [recommend contributor]. Question popularity: 19 [recommend question]
|
Research your answer: |



