Home » Learn C++ » Constructors of Multiple Inheritance

Constructors of Multiple Inheritance

Constructors of Multiple Inheritances:

            When a class is derived from more than one base class, the constructor of the derived class as well as of all its base classes arc executed when an object of the derived class is created.

            If the constructor functions have no parameters then first the constructor functions of the base classes are executed and then the constructor function of the derived class is executed.

 

Constructors in Multiple Inheritance with Arguments:

            To execute constructors of base classes that have arguments through the derived constructor functions, the derived class constructor is defined as:

 

  • Write the constructor function of the derived class with parameters.
  • Place a colon (:) immediately after this and then write the constructor function names of base classes with parameters separated by commas.

Other Topics

comment closed

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
Copyright © 2010 Information Village. All rights reserved.