[CPP] Multiple Inheritance
Multiple Inheritance In Java you can implement multiple interfaces but only extend one class In C++ you can inherit from(extend) multiple classes You will inherit all of the behaviour(i.e. function implementations), not just the interface. But be careful of multiple inheritance, because there are dangers, and confusing elements there may be easier ways(e.g. composition) There are multiple ways to support reuse of classes by new classes Composition/Aggregation Models the “has a” or “is a part of” relationship Composition is a stronger form • You need to expose the methods manually because they are on component objects Inheritance “is a” or “is a type of” ImplementationL Make the “type of” a sub-class Don’t use C-style casting to keep the code short! Use static_cast or dynamic_cast Dynamic cast will check(at runtime) that the pointer really is to an object of that type If you cast pointers or references when multiple inheritance is being used, then addres