previous | start | next

1.2.3 Constructors

In the initialization list for the Manager constructor, an Employee constructor can be passed parameters to initialize the Employee part of a Manager.

  Manager::Manager(const string& nm, double sal, int lev)
        : Employee(nm, sal), level(lev) 
  {}

The initialization of the base class occurs first, then the initialization of the derived class.

If no Employee constructor were listed in the initialization list, the Employee no argument constructor (if there is one) would be used to initialize the Employee part. If there were no effective no argument Employee constructor, an error occurs for the Manager constructor.



previous | start | next