#include using namespace std; class Clock{ private: int hour,minute,second; public: Clock(int h=0,int m=0,int s=0):hour(h),minute(m),second(s){}

void setClock(int h,int m,int s){
    hour=h;
    minute=m;
    second=s;
}

void showTime(){
    cout<<hour<<':'<<minute<<':'<<second<<endl;
}

};

int main(){ Clock c1(12,30,45); c1.showTime(); c1.setClock(15,20,10); c1.showTime();

Clock c2;
c2.showTime();
c2.setClock(8,0,0);
c2.showTime();

return 0;

}

C++ 时钟类实现:设计与功能

原文地址: https://www.cveoy.top/t/topic/l4tF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录