# Multiple inheritance and order of chaining of multiple base constructors [duplicate]

I am trying to understand the order of invocation of base class constructors in the presence of multiple inheritance. As far as I can tell, the order appears under-specified in the Solidity documentation below:

I have also gone through related questions in Stackexchange, but they do not address the issue with chaining multiple base constructors.

My understanding from Remix is that order of invocation of base constructors depends on the order of inheritance of the derived contract, and does not depend on the order in the constructor. For example, in both the cases below, the constructor for B is invoked before C.

``````contract B {
function B() public {emit PrintB();}
event PrintB();
}

contract C {
function C() public {emit PrintC();}
event PrintC();
}

contract D is B, C {
function D() C() B() {}
}

contract E is B, C {
function E() B() C() {}
}
``````

Can someone confirm if my understanding is correct?

If indeed my understanding is correct, is it documented in the Solidity specification, or is it just a feature of the current implementation and may change in the future.

Thanks for your help!

• The issue is different from the one pointed out. As far as understand, the C3 linearization of the inherited contracts is used to determine the method resolution order (which version of a method Foo in the contract hierarchy should a call Foo(..) be dispatched to). The question in ethereum.stackexchange.com/questions/21060/… is a clarification about the linearization. However, C3 linearization does not talk about the order of constructor calls when several constructors are chain in the derived contract, which was my question. Commented Apr 3, 2018 at 18:09

Solidity follows the path of Python and uses “C3 Linearization” to force a specific order in the DAG of base classes. This results in the desirable property of monotonicity but disallows some inheritance graphs. Especially, the order in which the base classes are given in the `is` directive is important.