I have the following constructor in my "fraction class"
fraction::fraction(int num, int den=1)
{
numerator=num;
denominator=den;
}
I also have a function called lcm()
that returns the least common multiple of values given as parameters. I need to overload the "+" operator in the class fraction. The operator "+" is to add two rational values.
Questions:
- Write the overloaded "+" operator as a member method of the class.
- Write the overloaded "+" operator as a friend function to the class.
- One of these gives an advantage over the other. Which one is better? Why is it better?
Any help will be greatly appreciated.