运算符重载
#include<iostream>
using namespace std;
class Time
{
public:
Time(){}
Time(int h,int m)
{
hour=h;
minute=m;
}
friend Time operator - (Time &a,Time &b)
{
Time c;
if(a.minute>b.minute&&a.hour<b.hour)
{
c.minute=(60-a.minute)+b.minute+(b.hour-a.hour-1)*60;
}
if(a.hour==b.hour)
{
c.minute=b.minute-a.minute;
}
if(a.minute<=b.minute)
{
c.minute=b.minute-a.minute+(b.hour-a.hour)*60;
}
return c;
}
void display()
{
cout<<minute<<endl;
}
private:
int hour;
int minute;
};
int main()
{
int x1,y1,x2,y2;
while(cin>>x1>>y1>>x2>>y2)
{
Time a(x1,y1),b(x2,y2),c;
if(x1==00&&y1==00&&x2==00&&y2==00)
{
break;
}
c=a-b;
c.display();
}
return 0;
}