time.cpp

来自「这个程序是对电梯的模拟」· C++ 代码 · 共 64 行

CPP
64
字号
// Time.cpp: implementation of the Time class.
//
//////////////////////////////////////////////////////////////////////

#include "Time.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Time::Time()
{

}

Time::~Time()
{

}

void Time::CurTime()
{
	time_t tt;
	tt=time(&tt);

    struct tm *t=localtime(&tt);
    hour=t->tm_hour;
	min=t->tm_min;
	sec=t->tm_sec;

}
int Time::operator < (Time & t2)
{
	if(hour < t2.hour)
		return 1;
	else if(hour > t2.hour)
		return -1;
	else if(min < t2.min)
		return 1;
	else if(min > t2.min)
		return -1;
	else if(sec < t2.sec)
		return 1;
	else if(sec > t2.sec)
		return -1;
	else return 0;
}

bool Time::operator > (Time & t2)
{
	if(hour > t2.hour)
		return true;
	else if(hour < t2.hour)
		return false;
	else if(min > t2.min)
		return true;
	else if(min < t2.min)
		return false;
	else if(sec > t2.sec)
		return true;
	else if(sec < t2.sec)
		return false;
	else return false;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?