Locked lesson.
About this lesson
Using other classes inside of your class.
Exercise files
Download this lesson’s related exercise files.
Class Inheritance.docx60.9 KB Class Inheritance - Solution.docx
60.2 KB
Quick reference
Class Inheritance
Class inheritance allows us to use other classes inside out classes.
When to use
Use this whenever you want to use something from one class in another class.
Instructions
Inheriting another class is pretty easy:
class Hired(Employee):
pass
That will allow the Hired class to inherit everything from the Employee class.
You can now access everything from the Employee class in your Hired instance.
Note: when instantiating a Hired object, you still need to pass whatever parameters that the Employee class requires!
Hints & tips
- Inheritance allows us to use other classes inside of other classes
- Just name the class you want to inherit from when creating your class
- class Hired(Employee): # now the Hired Class Inherits everything from the Employee Class
Lesson notes are only available for subscribers.