Constructors with inheritance

When an object of a derived type is created, its own constructor is invoked. If it wishes to invoke the constructor of its parent class it must do so explicitly as follows.

Dad::Dad(int x) { }

Fred::Fred(int x, int y) : Dad(x) { }

Where Fred is a class derived from Dad. We shall use this frequently in our case studies.

Next note in series

Back to index