← Constructors

Two Constructors

medium

Give Temperature two constructors: a default one that sets degrees to 0, and one that takes a starting value. main creates one object each way – Temperature freezing; (no arguments) and Temperature custom(37.5); (one argument) – and both need to work.

This is the same overload-resolution idea from this module’s first lesson, applied to constructors specifically: the compiler picks which constructor runs based on how many arguments the object is created with.

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