home | section main page


Table of Contents

1. Definition

In programming, inheritance is the adoption of attributes of a child class by that of a parent class. For instance, in this example:

class Animal:
    def __init__(self, birthday):
        self.weight = weight
        self.birthday = birthday

class Dog(Animal):

The class ~Dog~ will have the same fields as that of animal. In general, you can think of inheritance as taking on attributes from a node higher in the abstraction hierarchy.

Copyright © 2024 Preston Pan