#include<iostream> #include<algorithm> #include<iomanip> #include<cmath> #include<string.h> #include<stdlib.h> #include<sstream> #include<cmath> using namespace std; class clock{ private: int hour, minute, second; public: clock(int h = 0, int m = 0, int s = 0); void show(); clock operator++(); }; clock::clock(int h, int m, int s){ hour = h; minute = m; second = s; } void clock::show(){ cout << hour << ":" << minute << ":" << second << endl; } clock clock::operator++() { second++; if (second == 60){ second -= 60; minute++; if (minute == 60){ minute -= 60; hour++; hour %= 24; } } return *this; } int main() { clock ck(18, 59, 58), a; ck.show(); a = ck++; a.show(); return 0; }
我按照书敲得,可还是通过不了,书有好多错误。。。
求助改法
谢谢
onemoo
相关分类