Tutorials References Exercises Bootcamp Menu
Sign Up Create Website Get Certified Pro

C++ Multilevel Inheritance

Multilevel Inheritance

A class can also be derived from one class, which is already derived from another class.

In the following example, MyGrandChild is derived from class MyChild (which is derived from MyClass).


// Base class (parent)
class MyClass {
    void myFunction() {
      cout << "Some content in parent class." ;

// Derived class (child)
class MyChild: public MyClass {

// Derived class (grandchild)
class MyGrandChild: public MyChild {

int main() {
  MyGrandChild myObj;
  return 0;
Try it Yourself »