Fix issue #159
This commit is contained in:
parent
388564c9d9
commit
4ce9ef2078
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
设计一个时钟类,能够记录时、分、秒,重载它的++运算符,每执行一次++运算,加时1秒,但要使计时过程能够自动进位。
|
设计一个时钟类,能够记录时、分、秒,重载它的++运算符,每执行一次++运算,加时1秒,但要使计时过程能够自动进位。
|
||||||
*/
|
*/
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -12,7 +12,7 @@ class Time{
|
|||||||
}
|
}
|
||||||
void operator++();
|
void operator++();
|
||||||
void showTime(){
|
void showTime(){
|
||||||
cout<<"当前时间为:"<<hour<<":"<<minute<<":"<<second<<endl;
|
cout<<"当前时间为:"<<hour<<":"<<minute<<":"<<second<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -22,7 +22,7 @@ class Time{
|
|||||||
|
|
||||||
void Time::operator++(){
|
void Time::operator++(){
|
||||||
++second;
|
++second;
|
||||||
if(second=60){
|
if(second==60){
|
||||||
second=0;
|
second=0;
|
||||||
++minute;
|
++minute;
|
||||||
if(minute==60){
|
if(minute==60){
|
||||||
|
Loading…
Reference in New Issue
Block a user