#include<iostream>
using namespace std;
class Clock {
public:
Clock();
void setTime(int newH, int newM, int newS);
void showTime();
private:
int hour, minute, second;
};
Clock::Clock() :hour(0), minute(0), second(0) {}
void Clock::setTime(int newH, int newM, int newS) {
hour = newH; minute = newM; second = newS;
}
void Clock::showTime() {
cout << hour << ":" << minute << ":" << second << endl;
}
Clock globClock;
int main() {
cout << "First time out put:" << endl;
globClock.showTime();
globClock.setTime(8,30,30);
Clock myClock(globClock);
cout << "Second time out put" << endl;
myClock.showTime();
return 0;
}
标签:cout,5.6,Clock,int,void,showTime,globClock From: https://www.cnblogs.com/lml66/p/17378682.html