3.2. Defining a Class with a Member Function

We begin with an example (Fig. 3.1) that consists of class GradeBook (lines 8–16)—which, when it’s fully developed in Chapter 7, will represent a grade book that an instructor can use to maintain student test scores—and a main function (lines 19–23) that creates a GradeBook object. Function main uses this object and its displayMessage member function (lines 12–15) to display a message on the screen welcoming the instructor to the grade-book program.

 1   // Fig. 3.1: fig03_01.cpp 2   // Define class GradeBook with a member function displayMessage, 3   // create a GradeBook object, and call its displayMessage function. 4   #include <iostream> 5   using namespace std; ...

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.