Skip to Content
C++ How to Program, 10/e
book

C++ How to Program, 10/e

by Paul Deitel, Harvey Deitel
February 2016
Beginner
1080 pages
207h 57m
English
Pearson
Content preview from C++ How to Program, 10/e
... Alternate View

 1   // Fig. 4.6: Student.h
 2   // Student class that stores a student name and average.
 3   #include <string>
 4
 5   class Student {
 6   public:
 7       // constructor initializes data members
 8       Student(std::string studentName, int studentAverage)
 9          : name(studentName) {
10
11          // sets average data member if studentAverage is valid
12          setAverage(studentAverage);
13       }
14
15       // sets the Student's name
16       void setName(std::string studentName) {
17          name = studentName;
18       }
19
20       // retrieves the Student's name
21       std::string getName() const {
22          return name;
23       }
24
25       // sets the Student's average
26       void setAverage(int studentAverage) {
27          // validate that studentAverage is > 0 and <= 100; otherwise,
28          // keep data member average's current value
29          if
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ How to Program, Sixth Edition

C++ How to Program, Sixth Edition

P. J. Deitel - Deitel & Associates, Inc., H. M. Deitel - Deitel & Associates, Inc.
C++ How to Program, Ninth Edition

C++ How to Program, Ninth Edition

Paul Deitel, Harvey Deitel

Publisher Resources

ISBN: 9780134448930Purchase book