From the course: Getting Started with Python Object Oriented Programming: A Hands-On Approach

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Class inheritance: Introduction

Class inheritance: Introduction

- [Instructor] We now come to an important topic in object-oriented programming: class inheritance. Inheritance in OOP is where a class is created which inherits existing properties and methods from a base class or parent class. This means that we can leverage existing classes in our programs by extending and modifying them to suit our specific requirements. Class inheritance is often modeled using a UML diagram; a very simple example of which you can see on the screen. So you can see we have a base class from which are inheriting two subclasses. A couple of examples of how this might look in the real world are, for example, an animal base class, and then from that you have subclasses for mammal and reptile, for example, which would share some of the basic properties of an animal, but then have more specific properties to their own classes. And another example would be, say, a vehicle. And then from a vehicle you would have subclasses, for example, for cars, lorries or motorcycles.

Contents