Multilevel Inheritance in C++ Programming
Inheritance is the process of inheriting properties of objects of one class by objects of another class. The class which inherits the properties of another class is called Derived or Child or Sub class and the class whose properties are inherited is called Base or Parent or Super class. When a class is derived from a class which is also derived from another class, i.e. a class having more than one parent classes, such inheritance is called Multilevel Inheritance. The level of inheritance can be extended to any number of level depending upon the relation. Multilevel inheritance is similar to relation between grandfather, father and child.
For example,
- Student is derived from person and person is derived from class living things.
- Car is derived from vehicle and vehicle is derived from machine.
Syntax of Multilevel Inheritance
class base_classname { properties; methods; }; class intermediate_classname:visibility_mode base_classname { properties; methods; }; class child_classname:visibility_mode intermediate_classname { properties; methods; };