Also what would be a good way to prohibit denominator of 0? Throw exception or force it to be equal to 1?
That’s completely a style question, with no provably correct answer…
But… I’d go with an exception. Again, this is just style. Changing the value silently would be carrying on silently forward having done something other than what the caller asked for.
Another alternative would be to allow 0 denominator, but have a way to inform the user that the current overall value, a/b, is NaN or infinity, or whatever “special value” you care to define.
In any case, document it carefully, so a user of the class can make informed choices.
Your fraction constructor should take a numerator and a denominator as parameters (or a whole number). The entire problem could be solved easily with operator overloading.
And yes, the best way to handle failed constructors is via exceptions. Don’t forget to throw the same division_by_zero exception when you’re dividing two fractions and the numerator of the denominator is zero.