// time.h - header file for class Time (Nagler, p. 327 // - used by class AlarmClock) // cmc, 8/13/03 #ifndef TIME_H #define TIME_H #include class Time { inline friend std::ostream &operator<< (std::ostream &out, Time const &t) { return std::cout << (t.hours < 10 ? "0" : "") << t.hours << ':' << (t.minutes < 10 ? "0" : "") << t.minutes << ':' << (t.seconds < 10 ? "0" : "") << t.seconds; } public: // implicit inline functions Time(int h = 16, int m = 44, int s = 59) : hours(h), minutes(m), seconds(s) { } // ... don't need any more for this example private: int hours, minutes, seconds; }; #endif