GradeBook.cpp: Defining Member Functions in a Separate Source-Code File

Source-code file GradeBook.cpp (Fig. 3.12) defines class GradeBook’s member functions, which were declared in lines 11–14 of Fig. 3.11. The definitions appear in lines 9–33 and are nearly identical to the member-function definitions in lines 11–35 of Fig. 3.9. Note that the const keyword must appear in both the function prototypes (Fig. 3.11, lines13–14) and the function definitions for functions getCourseName and displayMessage (lines 22 and 28).

Each member-function name (lines 9, 16, 22 and 28) is preceded by the class name and ::, which is known as the scope resolution operator. This “ties” each member function to the (now separate) GradeBook class definition (Fig. 3.11 ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.