Defining and Testing Class GradeBook

Our next example (Fig. 3.3) redefines class GradeBook (lines 9–18) with a displayMessage member function (lines 13–17) that displays the course name as part of the welcome message. The new version of displayMessage requires a parameter (courseName in line 13) that represents the course name to output.

 1   // Fig. 3.3: fig03_03.cpp 2   // Define class GradeBook with a member function that takes a parameter, 3   // create a GradeBook object and call its displayMessage function. 4   #include <iostream> 5   #include <string> // program uses C++ standard string class  6   using namespace std; 7  8   // GradeBook class definition 9   class GradeBook10   {11   public:12      // function ...

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.