65,187
社区成员




#include <iostream>
using namespace std;
class Time
{
public:
Time();
friend ostream& operator<<(ostream& cout, Time& t);
Time& operator++()
{
this->sec++;
return *this;
}
Time operator++(int)
{
Time temp = *this;
this->sec++;
return temp;
}
private:
int sec;
};
Time::Time()
{
sec = 0;
}
ostream& operator<<(ostream& cout, Time& t)
{
cout << t.sec;
return cout;
}
int main()
{
Time t;
cout << t++ << endl;
cout << t << endl;
cout << ++(++t) << endl;
cout << t << endl;
system("pause");
return 0;
}