What is the difference between Multiple Inheritance and Polymorphism?
In a Book I red a line saying
there is no support for multiple inheritances at class level. This means you can’t extend more than one class at a time.
Which is contradicting the concept of Polymorphism, described in the same book as
polymorphism is the process of creating several objects from specific base classes
Now if Multiple Inheritance is not allowed in PHP then how the Polymorphism is allowed?
Like Ikke said, Multiple Inheritance has nothing to do with Polymorphism.
If I could draw a class diagram, Multiple Inheritance looks like this:
So, the class
Childwould inherit both attributes and behaviours from both classes. Many languages like Java and PHP don’t allow this, but Python does.Polymorphism, on the other hand, is when you can abstract out a specialisation. First of all, class diagram:
And you may do the following:
Each
petwill say different things depending on the implementation.