C++ actually allows a class to inherit from more than one class, and
this is referred to as multiple inheritance. But in C# and Java,
classes are only allowed to inherit from a single parent class, which is
called single inheritance.
Multiple inheritance allows people to create classes that combine aspects of different classes and their corresponding hierarchies. This is something that is quite common because applications often need to use the frameworks of different classes to achieve the desired functionality. Suppose that you are trying to create a class that models the animal known as a Liger, which is the result of having a Tiger and a Lion mate. Then you would create a class called Liger that derives from both the Tiger and Lion classes – so the Liger class would have to use multiple inheritance since it is deriving or inheriting from 2 different classes.
Multiple inheritance allows people to create classes that combine aspects of different classes and their corresponding hierarchies. This is something that is quite common because applications often need to use the frameworks of different classes to achieve the desired functionality. Suppose that you are trying to create a class that models the animal known as a Liger, which is the result of having a Tiger and a Lion mate. Then you would create a class called Liger that derives from both the Tiger and Lion classes – so the Liger class would have to use multiple inheritance since it is deriving or inheriting from 2 different classes.
No comments:
Post a Comment