Professional Documents
Culture Documents
class time
{
private:
int hours;
int minutes;
int seconds;
public:
time() : hours(0), minutes(0), seconds(0)
{ }
time checkTime(time t)
{
if(t.seconds>= 60)
{
t.seconds= t.seconds - 60;
++t.minutes;
}
if(t.minutes>=60)
{
t.minutes= t.minutes - 60;
++t.hours;
}
if(t.hours>=24)
t.hours= t.hours -24;
return time(t.hours, t.minutes, t.seconds);
} // To check the time for addition
time sCheck(time t)
{
if(t.seconds<0)
{
t.seconds = t.seconds + 60;
}
if(t.minutes<0)
t.minutes = t.minutes + 60;
if(t.hours<0)
t.hours = t.hours + 24;
return checkTime(time(t.hours, t.minutes, t.seconds));
} // to check the time for sub
};
int main()
{
time t1(25, 00, 59);
++t1;
t1 = t1.checkTime(t1); //It will correct the time
t1.displayTime(); // 01:02:00
�t1;
t1 = t1.checkTime(t1);
t1.displayTime();
return 0;
}