From the course: Programming Foundations: Object-Oriented Design

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using inheritance

Using inheritance - Python Tutorial

From the course: Programming Foundations: Object-Oriented Design

Start my 1-month free trial

Using inheritance

- [Instructor] I want to show you a few examples of how inheritance is implemented across several different languages to help you recognize inheritance when you see it in code. But don't worry about memorizing syntax here, this is just an overview. If I wanted to find a new class called CargoShuttle that inherits from an existing Spaceship class, in Java I would use the keyword extend followed by the name of the class I wanted to inherit from. So CargoShuttle extends Spaceship. In c#, I would use a colon, which is a fairly common way to indicate that CargoShuttle inherits from Spaceship. C++ and Swift both use a similar type of colon notation as well. Now Python is a bit different. Python puts the super class that the new subclass will inherit from in parentheses. And Ruby has its own way of saying that CargoShuttle inherits from Spaceship using the less than symbol. As you can see here, this basic idea of inheritance is really just a minor syntax change between languages. Now when it…

Contents