A key feature of object-oriented programming is inheritance. Inheritance is a mechanism that allows for a class's implementation to be derived from another class's implementation. This subclass/derived/child class inherits all of the attributes and methods of the superclass/base/parent class:
A practical real-world example of inheritance can be thought of with big cats. Cheetahs, leopards, tigers, and lions are all cats. They all share the same properties that are common to cats such as mass, lifespan, speed, and behaviors such as making vocalizations and hunting, among others. If we were to implement a Leopard, Cheetah, or Lion class, we would define one Cat class that has all of these properties and then derive the Leopard, Lion, and Cheetah classes from this Cat class since they all share these same properties. This would be inheritance.
We use inheritance because it confers the following benefits:
It makes our code more reusable. For example...