📄 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 + -