// z2.10-TimeHrMn.cc // #include using namespace std; class TimeHrMn { public: TimeHrMn(int timeHours = 0, int timeMinutes = 0); void Print() const; TimeHrMn operator+(TimeHrMn rhs) ; private: int hours; int minutes; }; // Overload + operator for TimeHrMn TimeHrMn TimeHrMn::operator+(TimeHrMn rhs) { TimeHrMn timeTotal; timeTotal.hours = hours + rhs.hours; timeTotal.minutes = minutes + rhs.minutes; return timeTotal; } TimeHrMn::TimeHrMn(int timeHours, int timeMinutes) { hours = timeHours; minutes = timeMinutes; } void TimeHrMn::Print() const { cout << "H:" << hours << ", " << "M:" << minutes << endl; } int main() { TimeHrMn time1(3, 22); TimeHrMn time2(2, 50); TimeHrMn timeTot; timeTot = time1 + time2; timeTot.Print(); return 0; }