# Inheritance

> A new class that gets all of an old class's parts, then adds its own.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Subclass, Child Class, Parent Class

## Think of it like

Think of it like a kid with a parent's eyes. The kid learns new tricks too.

## Definition

Inheritance lets a new class take on all the data and methods of a class that exists. Then it can add or change some. The old class is called the parent, and the new one is the child. A Cat class can get breathe from an Animal class and add its own meow. It saves writing the same code twice. Long chains of it, though, get hard to follow.

## Example

Jack has an Animal class with a breathe method. His Cat class inherits it, so every cat can breathe without new code.

## Example code

```python
class Animal:
    def breathe(self):
        return "in, out"

class Cat(Animal):
    pass

print(Cat().breathe())  # in, out
```

Cat writes no code of its own, yet it can breathe.

## Why it matters

It is the most common way to share code between related classes in OOP.

## Common mistake

Inheriting just to reuse one method. If a Cat is not truly a kind of the parent, pass the helper in instead.

## Three principles

- **Parent and child.** The child gets it all.
- **Add or change.** The child can do more.
- **Keep chains short.** Deep ones get confusing.

## Related terms

- [Class](https://learn.benibix.com/term/development/class)
- [Polymorphism](https://learn.benibix.com/term/development/polymorphism)
- [Object-Oriented Programming (OOP)](https://learn.benibix.com/term/development/object-oriented-programming)
- [Encapsulation](https://learn.benibix.com/term/development/encapsulation)
- [Composition (Programming)](https://learn.benibix.com/term/development/composition)

## Told apart from

- [Composition vs Inheritance](https://learn.benibix.com/compare/composition-vs-inheritance): Inheritance says a thing is a kind of another, like a cat is an animal. Composition says a thing has parts, like a car has an engine. Parts are easier to swap.
- [Inheritance vs Polymorphism](https://learn.benibix.com/compare/inheritance-vs-polymorphism): People think inheritance and polymorphism are one idea. They are not, though they often show up together. Inheritance is how one class gets the parts of another. Polymorphism is one method name that does the right thing for each kind of object. Python can have it with no parent class at all. Each object just needs the method.

---

Source: https://learn.benibix.com/term/development/inheritance
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
