Separating the Interface from the Implementation
In our prior examples, each class definition contained the complete definitions of the class’s
public member functions and the declarations of its
private data members. However, it’s better software engineering to define member functions outside the class definition, so that their implementation details can be hidden from the client code. This practice ensures that you do not write client code that depends on the class’s implementation details.
The program of Figs. 3.11–3.13 separates class
GradeBook’s interface from its implementation by splitting the class definition of Fig. 3.9 into two files—the header
GradeBook.h (Fig. 3.11) in which class
GradeBook is defined, and the source-code file