#include<iostream>
#include<windows.h>
using?namespace?std;
class?Clock{
????public:
????????Clock(short?h=0,short?m=0,short?s=0):h(h),m(m),s(s){
????????}
????????void?displayTime();
????private:
????????short?h;
????????short?m;
????????short?s;
};void?Clock::displayTime(){
????whiel(true)
????{
????????cout<<h<<':'<<m<<':'<<s;
????????Sleep(1000);
????????cout<<'\r';
????????if(!(s=++s%60))
????????????if(!(m=++m%60))
????????????????h=++h%24;
????}
}?int?main()
{
????Clock?A(23,59,55);
????A.displayTime();
????return?0;
}
如下時(shí)鐘程序中while(true)的作用是什么??在線等
小杜好機(jī)會(huì)啊
2016-03-13 14:49:52