multipliedBy()
needs to be something like this:
fraction fraction::multipliedBy(fraction f2)
{
fraction theAnswer(top, bottom);
theAnswer.top *= f2.top;
theAnswer.bottom *= f2.bottom;
return theAnswer;
}
You'll need to change the header too.
Note that this solution doesn't modify the fraction you are working on or f2
. It just returns a new fraction
with the answer in it.
You need (at least) a comment explaining why you have all of these members. Seems you only need a top and a bottom (whatever you call them).
- numerator
- denominator
- top
- bottom
- numAnswer
- denAnswer