/*。
*all right reserved,
*檔名:test.cpp
*完成日期:2023年5月7日
*版本號:v1.0
*問題描述:
*輸入描述:
*程式輸出:
*/#include using namespace std;
class ctime
;//建構函式
ctime::ctime(int h,int m,int s)
// 設定時間
void ctime::settime(int h,int m,int s)
//顯示時間
void ctime::display()
bool ctime::operator < (ctime &t)// 判斷時間t1t.hour) return false;
if (minutet.minute) return false;
if (secondt) return false;
return true;
}bool ctime::operator != (ctime &t) // 判斷時間t1!=t2
bool ctime::operator >= (ctime &t)// 判斷時間t1>=t2
bool ctime::operator <= (ctime &t) // 判斷時間t1<=t2
//二目運算子的過載
//加運算返回 t 規定的時、分、秒後的時間,例t1(8,20,25),t2(11,20,50),t1+t2為:41:15
ctime ctime::operator + (ctime &t)
if (m>59)
if (h>23) h-=24;
ctime t0(h,m,s);
return t0;
}//返回s秒後的時間
ctime ctime::operator+(int s)
// 計算時間之差
ctime ctime::operator - (ctime &t)
if (m<0)
if (h<0) h+=24;
ctime t0(h,m,s);
return t0;
}//返回s秒前的時間
ctime ctime::operator-(int s)
//賦值運算子的過載
//可以直接使用已經過載了的加減運算實現
//這種賦值, 例如 t1+=20,直接改變當前物件的值,所以在運算完成後,將*this作為返回值
ctime ctime::operator+=(ctime &c)
ctime ctime::operator-=(ctime &c)
ctime ctime::operator+=(int s)//返回s秒後的時間
ctime ctime::operator-=(int s)//返回s秒前的時間
第8周專案2 Time類中的運算子過載
檔名稱 main.cpp 作 者 姜 甜 甜 完成日期 2015年4月28日 版 本 號 v1.0 問題描述 實現time類中的運算子過載。includeusing namespace std class ctime ctime ctime int h,int m,int s void ctime ...
第12周專案2 Time類中的運算子過載
檔名 zhang.cpp 完成日期 2016年5月25日 版本號 v1.0 問題描述 實現time類中的運算子過載。includeusing namespace std class ctime ctime ctime int h,int m,int s hour h minute m second ...
第12周專案2 Time類中的運算子過載
檔名稱 time類中的運算子過載 作 者 岳成豔2016年5月25號 版 本 號 vc 6.0 問題描述 實現time類中的運算子過載。程式輸入 略 程式輸出 略 include using namespace std class ctime ctime ctime int h,int m,int ...