← Constructors

Fix: Missing Default Constructor

medium

main creates a Fraction with no arguments – and this class doesn’t compile, because it only defines a two-argument constructor. Submit it as-is and read the error before fixing anything.

This is the “quiet trap” from the lesson made concrete: writing the (int, int) constructor took away the free default constructor C++ would otherwise have generated. Add a Fraction() constructor of your own, initializing numerator to 0 and denominator to 1, so both ways of creating a Fraction work.

Your solution

"Run" uses the sample stdin (none). "Submit" checks your code against all 1 test case.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution