Does a derived class object contain a base class object?
问题 Consider the following sample code below: #include <iostream> using namespace std; class base { public: base() { cout << "ctor in base class\n"; } }; class derived1 : public base { public: derived1() { cout <<"ctor in derived class\n"; } }; int main() { derived1 d1obj; return 0; } Questions When d1obj is created, the constructors are invoked in the order of derivation : base class constructor is called first and then the derived class constructor. Is this done because of the following reason