I thought a lot (honestly) - from the last semester. And I'm still not quite sure what is happening here. Can anyone help and enlighten me? I'm fine with the pre / postfix difference. Itβs damn that the share is increasing, which scares me.
take an example of a prefix, for example. So, if I had a share that was 2/4, would it increase to 3/4? Because when I look at the number + = denomination, it makes me think that it will return 2 + 2 + 4, which is 8.
// prefix increment operator fraction& fraction::operator++() { numer += denom; return *this; } // postfix increment operator fraction fraction::operator++(int) { // Note dummy int argument fraction temp(*this); ++*this; // call the prefix operator return temp;
thanks for heaps in advance :)
source share