Question from a student:
I have a question about the 2nd question of assignment 02.
How do you want me to implement the add, sub, mul, and div member functions? Must a.add(b) affect the nominator / denominator values of object a, or must it return a third object of type Fraction containing the result?
Iâ€™ve also noticed that the formula for â€œProduct of two fractionsâ€ is incorrect. Must I use correct one of (ac)/(bd)?
a.add(b) should not affect a or b at all, i.e. it should return a third object of type Fraction. You should be able to use it as follows:
c = a.add(b);
Also, please use the correct formula (ac)/(bd) for the product of two fractions. Apologies for the mistake.
You need to start thinking more about fractions as whole objects instead of a collection of details.
To that end, your arithmetic operations are such that two Fraction objects are processed and a resultant Fraction object is returned. A slight difference is that you should take the one on the left hand side to be the one that actually does the operation and then creates a third Fraction. Your operations should thus be of the form: