O'Reilly logo

C++11 for Programmers, Second Edition by Harvey M. Deitel, Abbey Deitel, Paul J. Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing Counter-Controlled Repetition in Class GradeBook

Class GradeBook (Figs. 4.64.7) contains a constructor (declared in line 10 of Fig. 4.6 and defined in lines 9–12 of Fig. 4.7) that assigns a value to the class’s data member courseName (declared in line 16 of Fig. 4.6). Lines 16–26, 29–32 and 35–39 of Fig. 4.7 define member functions setCourseName, getCourseName and displayMessage, respectively. Lines 42–64 define member function determineClassAverage.

Because the gradeCounter variable (Fig. 4.7, line 46) is used to count from 1 to 10 in this program (all positive values), we declared the variable as an unsigned int, which can store only non-negative values (that is, 0 and higher). Local variables total (Fig. 4.7, line 45), grade ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required