You need to use constructors for:
1) correctly initializing variable members, and
2) creating objects with given initial values. Note that a fraction may have both a numerator and a denominator, for example: (8/3), or may simply be a number, for example: 6, in which case you will actually use (6/1) to represent it. Thus, the constructors with two and one arguments should be included in the class definition.
Your class will have a function for each one of the four operations. For example: Suppose we have defined objects a and b as two fractions, then to compute a + b, we will use:
When you conduct an operation, you do not have to simplify the result, i.e., 4/5 * 5/10 = 20/50.
Here are some of the rules you may need:
a/b + c/d = (a*d + b*c) / (b*d)
a/b - c/d = (a*d - b*c) / (b*d)
(a/b) * (c/d) = (a*c) / (b*d)
(a/b) / (c/d) = (a*d) * (c*b)
A more complicated version of this program is listed at the end of Chapter (6) - Problem 9.