class TIME
{
private:
int h;
int m;
int s;
public:
TIME(){};
~TIME(){};
TIME(int h,int m,int s)
{
this->h = h;
this->m = m;
this->s = s;
}
void add_s(int s)
{
this->s = this->s + s;
}
void set(int h,int m,int s)
{
if(h>23 || h < 0)
{
return ;
}
if(m>60 || m < 0)
{
return ;
}
if(s>60 || s < 0)
{
return ;
}
this->h = h;
this->m = m;
this->s = s;
}
void print()
{
printf("%02d:%02d:%02d",h,m,s);
}
};
简单的实现了一下,最好自己再调整一下。