Class inheritance
You use inheritance when you want to create a new, more functional class of code, based on some existing class of code. Inheritance is a tricky topic to cover. Let's start with the concept of a derived class (or subclass).
Derived classes
The most natural way to consider inheritance is by analogy with the animal kingdom. The classification of living things is shown in the following screenshot:
What this diagram means is that Dog, Cat, Horse , and Human are all Mammals. What that means is that dog, cat, horse, and human all share some common characteristics, such as having common organs (brain with neocortex, lungs, liver, and uterus in females), while being completely different in other regard. How each walks is different. How each talks is also different.
What does that mean if you were coding creatures? You would only have to program the common functionality once. Then, you would implement the code for the different parts specifically for each of the dog, cat, horse...