#include<iostream>
using namespace std;
class Time
{
friend ostream& operator<<(ostream& cout, Time& t);
friend istream& operator>>(istream& cin, Time& t);
public:
Time(int h = 0, int m = 0, int s = 0)
{
m_H = h;
m_M = m;
m_S = s;
}
Time& operator++();
Time operator++(int);
private:
int m_H;
int m_M;
int m_S;
};
Time& Time::operator++()
{
if (++m_S >= 60)
{
m_S -= 60;
++m_M;
}
if (m_M >= 60)
{
m_M -= 60;
++m_H;
}
if (m_H >= 24)
{
m_H -= 24;
}
return *this;
}
Time Time::operator++(int)
{
Time temp= *this;
m_S++;
if (m_S >= 60)
{
m_S -= 60;
++m_M;
}
if (m_M >= 60)
{
m_M -= 60;
++m_H;
}
if (m_H >= 24)
{
m_H -= 24;
}
return temp;
}
ostream& operator<<(ostream& cout, Time& t)
{
cout << t.m_H << ":" << t.m_M << ":" << t.m_S << endl;
return cout;
}
istream& operator>>(istream& cin, Time& t)
{
cin >> t.m_H >> t.m_M >> t.m_S;
return cin;
}
int main()
{
Time t1;
Time t2;
cout << "请输入时间t1的时,分,秒" << endl;
cin >> t1;
cout << "请输入时间t2的时,分,秒" << endl;
cin >> t2;
int i = 0;
int j = 0;
cout << "t1的电子钟模型如下" << endl;
for (i = 0; i < 61; i++)
{
++t1;
cout << t1 << endl;
}
cout << "t2的电子钟模型如下" << endl;
for (j = 0; j < 61; j++)
{
t2++;
cout << t2 << endl;
}
return 0;
}