The Time example consists of three files illustrating the organization of a larger, realistic program.
Time.h
Contains the class specification. Programs realize several benefits by separating the class description from the function definitions:
The class specification is easily and compactly included in documentation
Functions, which might embody trade secrets, are delivered to clients in machine code rather than full source code
programs only have a single copy of the functions' machine code
It's easier to build and manage client programs that use the class in some but not all of its files
It's easier to reuse the class in other programs
Time.cpp
contains the member function definitions. Programs only need one copy of these functions. The linker joins the functions' machine code in this file with the calls made throughout the program.
driver.cpp
represents a client of the Time class. In a larger, more realistic program, the client code will typically span many files - some, but perhaps not all, of those files will use the services of a specific class.
The textbook introduced the Time program in Chapter 4 as a structure example. We updated it in Chapter 5, demonstrating three ways to pass structures to functions: (a) by value, (b) by pointer, and (c) by reference. Parts of the Time class have been presented in the preceding sections of this chapter to illustrate various aspects of object-oriented programming. The following figures present the complete, final version of the program.