Lecture 5 - Slide 3 : 40
Inheritance: Constructors and destructors
Constructors in class hierarchies work as expected in C++
About constructors
The C++ Prog. Lang. (3. edition)
:
Page 306
The C++ Prog. Lang. (4. edition)
: Page 582
Constructor rules
A subclass constructor invoke the superclass constructors -
implicitly
or
explicitly
Constructors with parameters must be invoked explicitly
Default constructors can be invoked implicitly
Bottom up construction and top down destruction
First base class constructors, then derived class constructors
Multiple base classes are constructed in their declaration order
C++ allows for inheritance of constructors
Makes sense if a derived class does not add data members.
Examples next slide