#ifndef TIMER_H #define TIMER #include //for class ostream #include //for the i/o manipulator setw using namespace std; class timer { int hours; int minutes; int seconds; public: timer(int h, int m, int s): hours {h}, minutes {m}, seconds {s} {} ~timer() {cout << "Time's up!\n";} timer& operator--(); //prefix decrement, too big to be inline operator int() const {return seconds + 60 * (minutes + 60 * hours);} friend ostream& operator<<(ostream& ost, const timer& t) { //Output each value as a two-digit number. return ost << setfill('0') << setw(2) << t.hours << ":" << setw(2) << t.minutes << ":" << setw(2) << t.seconds; } }; inline const timer operator--(timer& t, int) //postfix decrement { const timer old {t}; --t; //d.operator--(); //calls prefix decrement to do most of its work return old; } #endif