#include #define OPCIONAL 1 class Time { int hours; int minutes; int seconds; public: explicit Time(int hh = 0, int mm = 0, int ss = 0) : hours(hh), minutes(mm), seconds(ss) { } #if SOLUCION Time operator+(const Time& other) const { return Time(hours + other.hours, minutes + other.minutes, seconds + other.seconds); } #elif OPCIONAL Time operator+(const Time& other) const { int ss = seconds + other.seconds; int css = ss / 60; int mm = minutes + other.minutes; int cmm = (mm + css) / 60; int hh = hours + other.hours; //int chh = (hh + cmm) / 24; return Time((hh + cmm) % 24, (mm + css) % 60, ss % 60); } #endif friend inline std::ostream& operator<<(std::ostream& out, const Time& time) { return out << time.hours << ':' << time.minutes << ':' << time.seconds; } }; int main() { Time actual(13, 30); Time periodo(8); Time pildora1 = actual + periodo; Time pildora2 = pildora1 + periodo; std::cout << "Son las " << actual << std::endl; std::cout << "Proxima pildora a las " << pildora1 << std::endl; std::cout << "Y la siguiente a las " << pildora2 << std::endl; }