![]() |
#2
aipb20072007-06-06 10:19
|
class Time
{
int hour,minute,second;
public:
void time(int h,int m,int s);
void set(int h,int m,int s);
void display();
};
void Time::time(int h,int m,int s)//定义时间
{
if(h<0||h>=60||m<0||m>=60||s<0||s>=60)
{
cerr<<"Time isn't right!\n"; exit(-1);
}
hour=h;minute=m;second=s;
}
void Time::set(int h,int m,int s)//调整时间
{
if(h<0||h>=60||m<0||m>=60||s<0||s>=60)
{
cerr<<"Time isn't right!\n"; exit(-1);
}
hour=h;minute=m;second=s;
}
void Time::display()//显示时间
{
cout<<"The time is"<<hour<<":"<<minute<<":"<<second<<endl;
}