Increment
Two operators: prefix increment & postfix increment
// prefix increment
MyTime& operator++()
{
this->minutes++;
this->hours += this->minutes / 60;
this->minutes = this->minutes % 60;
return *this;
}
// postfix increment
MyTime operator++(int)
{
MyTime old = *this; // keep the old value
operator++(); // prefix increment
return old;
}
C++中可以重载的运算符