When a derived class object is created using constructors, it is created in the following order:
In the following code fragment, the constructor for class B1
is called before the member d1 is initialized. The value passed
to the constructor for class B1 is undefined.
class B1
{
int b;
public:
B1();
B1(int i) {b = i;}
};
class D : public B1
{
int d1, d2;
public:
D(int i, int j) : d1(i), B1(d1) {d2 = j;}
// d1 is not initialized in call B1::B1(d1)
};
![]()
Constructors and
Destructors Overview
![]()
Initializing Base Classes and Members
Initialization by Constructor
Constructors
Derivation