// A class of times -- OOP #include using namespace std; class Time { public: void read(istream& in = cin) { in >> hours; in.get(); // colon in >> minutes; } void print(ostream& out = cout) { out << hours << ':'; if (minutes < 10) { out << 0; } out << minutes; } bool less_than(const Time& t) { // return (hours * 60 + minutes) < (t.hours * 60 + t.minutes); return (hours < t.hours) || (hours == t.hours && minutes < t.minutes); } private: int hours; int minutes; }; // Test driver for Time int main() { Time t; t.read(); t.print(); cout << endl; Time t2; t2.read(cin); if (t.less_than(t2)) { cout << "The first time occurs before the second one.\n"; } else { cout << "The first time does not occur before the second one.\n"; } return 0; }