Date Class’s Default Copy Constructor
As you study class
Date (Fig. 9.17), notice that the class does not provide a constructor that receives a parameter of type
Date. So, why can the
Employee constructor’s member initializer list initialize the
hireDate objects by passing
Date objects to their
Date constructors? As we mentioned in Section 9.9, the compiler provides each class with a default copy constructor that copies each data member of the constructor’s argument object into the corresponding member of the object being initialized. Chapter 10 discusses how you can define customized copy constructors.