From 75a76916108adbfd0e7fb818dcbf9a657b68e3a2 Mon Sep 17 00:00:00 2001 From: zhkgo <39695505+zhkgo@users.noreply.github.com> Date: Wed, 2 Mar 2022 14:05:51 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E9=87=8D=E8=BD=BD++=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E9=92=9F.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了++的时候判断时使用if(second=60)的bug,增加了后缀形式的++重载,完善了++的返回值。 --- .../day4/时钟练习题/重载++的时钟.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/practical_exercises/10_day_practice/day4/时钟练习题/重载++的时钟.cpp b/practical_exercises/10_day_practice/day4/时钟练习题/重载++的时钟.cpp index e85fd20..2a2767f 100644 --- a/practical_exercises/10_day_practice/day4/时钟练习题/重载++的时钟.cpp +++ b/practical_exercises/10_day_practice/day4/时钟练习题/重载++的时钟.cpp @@ -1,5 +1,5 @@ /* -һʱܹ࣬¼ʱ֡룬++ÿִһ++㣬ʱ1룬ҪʹʱܹԶλ +设计一个时钟类,能够记录时、分、秒,重载它的++运算符,每执行一次++运算,加时1秒,但要使计时过程能够自动进位。 */ #include using namespace std; @@ -10,19 +10,24 @@ class Time{ minute = m; second = s; } - void operator++(); + Time operator++(); + Time operator++(int); void showTime(){ - cout<<"ǰʱΪ"<