// A class of times -- encapsulation #include using namespace std; class Time { friend void read(Time& t, istream& in); friend void print(const Time& t, ostream& out); private: int hours; int minutes; }; void read(Time& t, istream& in = cin) { in >> t.hours; in.ignore(); // colon in >> t.minutes; } void print(const Time& t, ostream& out = cout) { out << t.hours << ':'; if (t.minutes < 10) { out << 0; } out << t.minutes; } // Test driver for Time int main() { Time t; read(t); print(t); return 0; }