#include<iostream>
using namespace std;
class Clock
{
private:
int hour;
int minute;
int second;
public:
Clock(int h = 0, int m = 0, int s = 0)
{
hour = h; minute = m; second = s;
}
void setTime(int h, int m, int s);
void showTime();
bool operator >(Clock & c);
bool operator <(Clock & c);
};
void Clock::setTime(int h, int m, int s)
{
hour = h;
minute = m;
second = s;
}
void Clock::showTime()
{
cout << "现在时间:" << hour << ":" << minute << ":" << second << endl;
}
bool Clock::operator>(Clock & c)
{
if(this->hour>c.hour)
return this->hour>c.hour;
else if(this->hour==c.hour)
return this->minute>c.minute;
else if(this->hour==c.hour&&this->minute==c.minute)
return this->second>c.second;
else false;
}
bool Clock::operator<(Clock & c)
{
return c > *this;
}
int main()
{
Clock c1(19, 58, 23),c2(19,25,23);
c1.showTime();
c2.showTime();
if(c1>c2)
{
cout << "c1" << endl;
}
if(c1 < c2)
{
cout << "c2" << endl;
}
return 0;
}