CJCoding With Joseph
15free / daySign inCreate account

Reusing an Inherited Setter and Getter

When base data is private, a derived class cannot touch it directly and must go through the inherited public accessors.

Base class Temperature (already written) has a PRIVATE double celsius with void setCelsius(double c) and double getCelsius() const.

Create a derived class Weather with a method double toFahrenheit() const that uses the inherited getCelsius() to compute celsius * 9.0 / 5.0 + 32.0.

For 100 degrees Celsius the result is 212.0. The runner prints it with one decimal place (see Expected Output).

Do NOT write a main function.

Expected Output:

212.0

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
Inheritance
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.