... // print Employee object
23   string Employee::toString() const {
24      ostringstream output;
25      output << lastName << ", " << firstName << " Hired: "
26         << hireDate.toString() << " Birthday: " << birthDate.toString();
27      return output.str();
28   }
29
30   // output Employee object to show when its destructor is called
31   Employee::~Employee() {
32      cout << "Employee object destructor: "
33         << lastName << ", " << firstName << endl;
34   }

Employee Constructor’s Member-Initializer List

The colon (:) following the constructor’s header (Fig. 9.21, line 13) 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, ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.