Why does error appear when I output like the following example? *In my class CTimeSpan, I create like the following example: It's error cout<<tm1++;
#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++;
}
*thank you very much. Help me.