冉冉说
#include<iostream.h>#include<windows.h>class clock{private:int hour;int minute;int second;public:clock(int h,int m,int s);void run_time(int s);void show_time();};clock::clock(int h,int m,int s){hour=h;minute=m;second=s;}void clock::show_time(){cout<<hour<<":"<<minute<<":"<<second<<endl;}void clock::run_time(int s){for(int i=0;i<s;i++){second++;if(second==60){minute++;second=0;if(minute==60){hour++;minute=0;if(hour==24){hour=0;}}}system("cls");show_time();//函数调用Sleep(1000);//该句的头文件是#include<windows.h>,沉睡效果,可不要}}void main(){clock a(22,47,58);//初始时间a.show_time();//输出a.run_time(10);//补充的走时函数}