Inheriting from Multiple Classes
Learn how a class can inherit from multiple classes using multilevel inheritance
Up until now, we have looked at how a (child) class can inherit from another (parent) class. But in C++, it's also possible that a class can inherit from more than one base class. This can be done using different methods. Let’s explore some of these methods and the potential issues that can arise with this.
Multilevel Inheritance
To understand multilevel inheritance, imagine a family tree. In a family tree, there can be grandparents, parents, and children. In programming, this is similar to multilevel inheritance.
Multilevel inheritance occurs when a class is derived from another derived class. This means that a class (child class) inherits from a base (parent) class, and this base (parent) class is also inherits from another base (grandparent) class. This can be illustrated as:
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy