一、重载时间类小于号:
bool operator<(const Time&t)const{
if(year!=t.year)
return year<t.year;
else if(month!=t.month)
return month<t.month;
else
return day<t.day;
}
注意重载小于号要有2个const,注意后面的const。
二、重载==号
bool Time::operator==(const Time &d)
{
if(yeard.year&&monthd.month&&day==d.day)
return true;
else
return false;
}