October 2004
Intermediate to advanced
240 pages
6h 22m
English
Virtual functions only “virtually” always behave virtually: Inside constructors and destructors, they don’t. Worse, any direct or indirect call to an unimplemented pure virtual function from a constructor or destructor results in undefined behavior. If your design wants virtual dispatch into a derived class from a base class constructor or destructor, you need other techniques such as post-constructors.
In C++, a complete object is constructed one base class at a time.
Say we have a base class B and a class D derived from B. When constructing a D object, while executing B’s constructor, the dynamic type of the object under construction is B. In particular, ...