解题报告:

include <iostream>

using namespace std;

class calculate //定义计数器类
{
protected:
int value; //包含保护数据成员value

public:
calculate(int V = 0) : value(V) {} //构造函数
void increment() { value++; } //公有函数increment计数加1
friend class cclock; //友元函数
};

class cycle : public calculate //定义循环计算器,继承计数器类
{
private:
int min_value, max_value; // 增加私有数据成员:最小值min_value,max_value,
public:
cycle(int V = 0, int I = 0, int A = 60) : calculate(V), min_value(I), max_value(A) {}
void getvalue(int v)
{
value = v;
}
void changemax()
{
max_value = 24;
}

int increment(int d) //重写公有函数increment,使得value在min_value~max_value区间内循环+1。
{//d为增加的秒数
    int cnt = 0;
    for (int i = 0; i < d; i++) 
    {
        value++;
        if (value >= max_value)
        {
            value -= max_value;
            cnt++;
        }
    }
    return cnt;
}
friend class cclock;

};

class cclock //定义时钟类//因为clock是系统内置函数,为了避免重名,请不要使用clock作为类名或者函数名
{
private: //数据成员是私有循环计数器对象
cycle hour, minute, second; //小时hour、分钟minute、秒second

public:
cclock(int H, int M, int S)
{
hour.getvalue(H);
hour.changemax();
minute.getvalue(M);
second.getvalue(S);
}
void time(int delta) //公有函数time(int s)计算当前时间经过s秒之后的时间
{ //即hour,minute,second的新value值。
int cnt = 0;
cnt = second.increment(delta);
cnt = minute.increment(cnt);
hour.increment(cnt);
cout << hour.value << ":" << minute.value << ":" << second.value << endl;
}
};

int main()
{
int t;
cin >> t;
while (t--)
{
int h, m, s;
cin >> h >> m >> s;//当前时间(小时 分钟 秒)
//定义时钟类对象,输入当前时间和经过的秒数,调用time函数计算新时间。
cclock B(h, m, s);
int d;
cin >> d;//经过的秒数
B.time(d);
}
return 0;
}