I've given this a lot of thought (honestly) - since last semester. And I'm still not entirely sure what is going on here. Would anyone be able to help and enlighten me? I'm ok with the pre/postfix difference. It's how the hell the fraction is being incremented which is confusing the hell out me
take the prefix example for instance. So if I had a fraction which was 2/4 would that increase to 3/4? Because when I look at numer += denom, 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 heaps in advance :)