Functions
Functions cannot access the internal (private) structure of any class, unless declared as a friend.
const rational abs (const rational & num) { // return the absolute value of a rational number int newtop; int newbottom = num.denominator(); // get non-negative numerator part if (num.numerator() < 0) newtop = - num.numerator(); else newtop = num.numerator(); // create and return result return rational(newtop, newbottom);}