Employee Constructor’s Member Initializer List

The colon (:) following the constructor’s header (Fig. 9.20, line 12) begins the member initializer list. The member initializers specify the Employee constructor parameters being passed to the constructors of the string and Date data members. Parameters first, last, dateOfBirth and dateOfHire are passed to the constructors for objects firstName (line 12), lastName (line 13), birthDate (line 14) and hireDate (line 15), respectively. Again, member initializers are separated by commas. The order of the member initializers does not matter. They’re executed in the order that the member objects are declared in class Employee.


Image Good Programming Practice 9.3

For clarity, list member initializers in the order that the class’s data members are declared.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.247.81