Time Class Definition

The class definition (Fig. 9.1) contains prototypes (lines 13–16) for member functions Time, setTime, printUniversal and printStandard, and includes private unsigned int members hour, minute and second (lines 18–20). Class Time’s private data members can be accessed only by its member functions. Chapter 11 introduces a third access specifier, protected, as we study inheritance and the part it plays in object-oriented programming.

 1   // Fig. 9.1: Time.h  2   // Time class definition.                   3   // Member functions are defined in Time.cpp  4  5   // prevent multiple inclusions of header 6   #ifndef TIME_H  7   #define TIME_H  8  9   // Time class definition10   class Time11   {

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.