?? h6.cpp
字號:
using namespace std;class Time{private: int h, m, s;public: Time(int hx = 0, int mx = 0, int sx = 0); Time& increaseSecond(int s); //增加 Time& increaseMinute(int m); //增加分 Time& increaseHour(int h); //增加小時 bool equal(const Time& temp); //判定是否相等 void print(); //輸出};//方法實現如下:Time::Time(int hx, int mx, int sx){ h=hx; m=mx; s=sx;}Time& Time::increaseSecond(int s){ this->s+=s; if(this->s<60) return *this; else { this->s-=60; this->m++; } }Time& Time::increaseMinute(int m){ this->m+=m; if(this->m<60) return *this; else { this->m-=60; this->h++; }} Time& Time::increaseHour(int h){ this->h+=h; if(this->h<=24&&this->h>=0) return *this;}bool Time::equal(const Time& temp){ if(s==temp.s&&m==temp.m&&h==temp.h) return true; else return false;}void Time::print(){ cout<<"Now it's"<<h<<":"<<m<<":"<<s<<endl;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -