Pass by value initializes a function parameter with a copy of the argument. In C++, that copy can invoke a copy constructor and later a destructor. section 6.2.2
Passing objects by value can create hidden runtime work:
- Calling append with a Date by value copies the argument before vector insertion. section 6.2.2
- Passing Appointments by value copies the container and its Date elements before print executes. section 6.2.2
- Vector growth can copy existing elements, then deallocate the old array and temporary objects. section 6.2.2
Instrumented Date and Appointments
An instrumented Date class prints constructor, copy-constructor, assignment, and destructor calls. Running append and print exposes repeated copies, allocations, and deallocations that ordinary output hides.


