示例#1
0
bool operator!=(const Clock a, const Clock b)
{
    if (a.getHour() == b.getHour() && a.getMin() == b.getMin() && a.getSec() == b.getSec())
    {
        return false;
    }
    else {return true;}
}
示例#2
0
Clock operator+(Clock a, const Clock b)
{
    a.setHour(a.getHour() + b.getHour());
    a.setMin(a.getMin() + b.getMin());
    a.setSec(a.getSec() + b.getSec());
    	while(a.getSec() >= 60)
	{
		a.setMin(a.getMin()+1);
		a.setSec(a.getSec()-60);
	}
		while(a.getMin() >= 60)
	{
		a.setHour(a.getHour()+1);
		a.setMin(a.getMin()-60);
	}
	while(a.getHour() >= 24) { a.setHour(a.getHour()-24); }
    return a;
}
示例#3
0
Clock operator-(Clock a, const Clock b)
{
    a.setHour(a.getHour() - b.getHour());
    a.setMin(a.getMin() - b.getMin());
    a.setSec(a.getSec() - b.getSec());
    	while(a.getSec() < 0)
	{
		a.setMin(a.getMin()-1);
		a.setSec(a.getSec()+60);
	}
		while(a.getMin() < 0)
	{
		a.setHour(a.getHour()-1);
		a.setMin(a.getMin()+60);
	}
	while(a.getHour() < 0 ) { a.setHour(a.getHour()+24); }
    return a;
}