#include <iostream> using namespace std; class Time { public: int hours; // 小时 int minutes; // 分钟 Time() { hours = 0; minutes = 0; } Time(int h, int m) { this->hours = h; this->minutes = m; } void show() { cout << hours << " " << minutes << endl; } // write your code here...... Time operator+(Time p){//+表示的是加号的重载 Time t; t.hours=p.hours+this->hours;//将两个hours加起来 t.minutes=p.minutes+this->minutes;//将两个minutes加起来 t.hours+=t.minutes/60; t.minutes=t.minutes%60;//不要忘了minutes小于60 return t; } }; int main() { int h, m; cin >> h; cin >> m; Time t1(h, m); Time t2(2, 20); Time t3 = t1 + t2; t3.show(); return 0; }