C++C++11C++14C++17Introduction to C++Learn C++

Learn C++ Inheritance :: Multilevel Inheritance

Inheritance allows us to define a class in terms of another class, and it makes easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and fast implementation time. If a class is derived from another derived class then it is called multilevel inheritance. In other terms, multilevel inheritance method is using a class which has more than one parent class. Multilevel Inheritance differences from the Multiple Inheritance because of it has a previous class in each levels of new class definitions.

Here is a multilevel inheritance example,

For example, if we take lives as a base class then animals are the derived class which has features of animals and then mammals are the also derived class that is derived from sub-class animal which inherit all the features of lives.

From this example, we prepared a Multilevel Inheritance example below,

Here all lives has weight, and animals has a type value and mammals has number of legs. We define an elephant object as a mammal, and we are able to reach all properties and methods of mammals, animals derived classes and lives base class.

Get started building powerful apps with C++Builder!

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?

Worth reading...
Learn about Polymorphism :: Pointers to Base Classes in C++