What is the difference between operator++ () and operator++ (int)?

Viewed 1609

I have these code of lines from a program my teacher made :

 TimeKeeper& operator++() {
        d_seconds++;
        return *this;
  }
  const TimeKeeper operator++(int) {
        TimeKeeper tk(*this);
        ++(*this);
        return tk;
  }

And one of the questions my teacher asked us was "operator++() returns a reference and operator++ (int) returns a value, explain why?"

Can anyone explain this to me?? If you need the rest of the code i dont mind putting it on! Thanks!!

3 Answers
Related