问题描述
为什么我像下面的例子那样输出时会出现错误? *在我的类 CTimeSpan 中,我创建如下示例: 这是错误 cout
#include <iostream>
using namespace std;
class CTimeSpan {
private:
unsigned int day; //day
unsigned int hour;
unsigned int minute;
unsigned int second;
public:
ostream& operator<<(ostream& os,const CTimeSpan& tm)
{
os << tm.day << "d"
<< " " << tm.hour << "h"
<< " " << tm.minute << "p"
<< " " << tm.second << "s";
return os;
}
CTimeSpan CTimeSpan::operator++(int s) {
CTimeSpan temp = *this;
++* this;
return temp;
}
};
int main()
{
CTimeSpan tm1{ 1,2,3,4 };
cout << tm1++;
}
*非常感谢。帮帮我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)