# Include <iostream>
Using namespace STD;
Class Base
{
PRIVATE:
Int
A;
Public:
Base (int I)
{A = I; cout <"constructing base A =" <A <Endl;}
~ Base ()
{Cout <"destroying base A =" <A <Endl;
}
};
Class Derived: public Base
{
PRIVATE:
Int
D;
Base
Member;
Public:
// Pass Parameter I to the base-class constructor, and the object member constructor passes parameter J
// Although Member (j) is in the front of the initialization list, the base class constructor is called first, followed by the object member constructor,
// Finally, execute the constructor of the derived class. When there are multiple object members, the calling sequence of these Members depends on the fact that they are in the derived class.
// Explain order
Derived (int I, Int J, int K): Member (J), base (I)
{
D = K;
Cout <"constructing derived d =" <D <Endl;
}
~ Derived ()
{Cout <"destroying derived d =" <D <Endl;
}
};
Void Main ()
{
Derived
D (5, 8, 9 );
}