1 #include<iostream> 2 using namespace std; 3 class zhong 4 { 5 private: 6 int shi; 7 int fen; 8 int miao; 9 public: 10 zhong operator++() 11 { 12 miao++; 13 if(miao==60) 14 { 15 fen++; 16 miao=0; 17 } 18 if(fen==60) 19 { 20 shi++; 21 fen=0; 22 } 23 if(shi==24) shi=0; 24 return *this; 25 } 26 zhong operator++(int) 27 { 28 zhong a=*this; 29 ++*this; 30 return a; 31 } 32 friend istream& operator>>(istream& input,zhong& a) 33 { 34 input>>a.shi>>a.fen>>a.miao; 35 return input; 36 } 37 friend ostream& operator<<(ostream& output,zhong& a) 38 { 39 output<<a.shi<<":"<<a.fen<<":"<<a.miao; 40 return output; 41 } 42 }; 43 int main() 44 { 45 zhong a; 46 cin>>a; 47 a++; 48 cout<<a; 49 }
标签:++,zhong,miao,fen,int,5.11,shi From: https://www.cnblogs.com/lijianlongCode13/p/17392363.html