Multiple Inheritance

Multiple Inheritance :

When a class inherits two or more than two classes, then its callled multiple inheritance.

  • When an object of a child class is created, the constructors are called in the sequence in which the parent are inherited.(like in following syntax, first base1, then base2 and so on…)
  • Syntax to define a derived class inheriting more than one class is :
    class derived_class_name: access-spec base1, access-spec base2,….
Following example illustrates the multiple inheritance in C++ :

OUTPUT :

 

Leave a Reply

Your email address will not be published. Required fields are marked *