引用传递出现错误
#includeusing namespace std;class Time{private: int h_,m_,s_;public: Time():h_(0),m_(0),s_(0) { } Time(int h,int m,int s):h_(h),m_(m),s_(s) { } Time(const Time& rhs){ h_=rhs.h_; m_=rhs.m_; s_=rhs.s_; } Time(Time& rhs){ h_=rhs.h_; m_=rhs.m_; s_=rhs.s_; } Time& operator = (Time& x){ *this=x; return x; } ~Time() {} Time& operator++() { int n; if(h_>=24||h_<0||m_<0||m_>=60||s_<0||s_>=60) { } else { n=h_*60*60+m_*60+s_; n+=1; if(n>=24*60*60) { n-=24*60*60; h_=n/60/60%24; m_=n/60%60; s_=n%60; } else { h_=n/60/60%24; m_=n/60%60; s_=n%60; } } return *this; } /* Time& operator++(int) { //Time p(*this); int a=h_; int b=m_; int c=s_;// cout<=24||h_<0||m_<0||m_>=60||s_<0||s_>=60) { }// else// {// n=h_*60*60+m_*60+s_;// n+=1;// if(n>=24*60*60)// {// n-=24*60*60;// h_=n/60/60%24;// m_=n/60%60;// s_=n%60;// }// else// {// h_=n/60/60%24;// m_=n/60%60;// s_=n%60;// }// } Time t(a,b,c);// cout<=24||h_<0||m_<0||m_>=60||s_<0||s_>=60) { } else {n=h_*3600+m_*60+s_; n-=1; if(n<0) { n+=86400; h_=n/3600%24; m_=n/60%60; s_=n%60; } else { h_=n/3600%24; m_=n/60%60; s_=n%60; } } return *this; } Time& operator--(int) { //Time p(*this); int a,b,c; a=h_;b=m_;c=s_; Time p(a,b,c);// int n;// if(h_>=24||h_<0||m_<0||m_>=60||s_<0||s_>=60) { }// else// {n=h_*3600+m_*60+s_;// n-=1;// if(n<0)// {// n+=86400;// h_=n/3600%24;// m_=n/60%60;// s_=n%60;// }// else// {// h_=n/3600%24;// m_=n/60%60;// s_=n%60;// }// } return p; } friend istream& operator >> (istream& in,Time& x){ in>>x.h_>>x.m_>>x.s_; return in; } friend ostream& operator << (ostream& out,Time& x){ cout<<"********"<=0&&x.h_<=23&&x.m_>=0&&x.m_<=59&&x.s_>=0&&x.s_<=59) out<>cases; cout<>t; Time c = t; cout<<"&&&"<
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~