
Envoyé par
Le standard 12.6.2/5
Initialization shall proceed in the following order:
— First, and only for the constructor of the most derived class as described below, virtual base classes shall be initialized in the order they appear on a depthfirst lefttoright traversal of the directed acyclic graph of base classes, where “lefttoright” is the order of appearance of the base class names in the derived class basespecifierlist.
— Then, direct base classes shall be initialized in declaration order as they appear in the basespecifierlist (regardless of the order of the meminitializers).
— Then, nonstatic data members shall be initialized in the order they were declared in the class definition (again regardless of the order of the meminitializers).
— Finally, the body of the constructor is executed.
[Note: the declaration order is mandated to ensure that base and member subobjects are destroyed in the reverse order of initialization. ]
Partager