Polymorphism is one of the four pillars of Object Oriented Programming
Inheritance is probably the easiest of all the concepts of Object Oriented programming to understand. But it is one of the more difficult to implement properly.
Inheritance means that a class can inherit from another class. To be strictly correct this is called Implementation Inheritance. There is also a related, but different, procedure called Interface Inheritance. We won't be separating the two here. Indeed, in the programming world it isn't always necessary to separate the two. But sometimes it is.
Let's look at an example, and it is an example that has been used since time immemorial. Suppose we have a class dog and another class cat. These are likely to be similar classes in a number of respects. And we can emphasise that fact by creating a third class animal and have both of the dog and cat classes inherit from it.
This means that any properties or fields which are contained in animal are also contained in dog and cat. We looked at this in the article on Polymorphism.
The important thing about inheritance is that there must be an "is a" relationship between the base class and the derived class. In this case dog is an animal.
This is not always as simple as it seems. Many OO gurus suggest, and I agree with them, that inheritance should be viewed with suspicion and that often composition or aggregation, where one class contains or references another, may be a better solution.
This is not to say that you shouldn't use inheritance. It is a very powerful component of OO programming, and we would be lost without it.
Cats are intended to teach us that not everything in nature has a function.