CJCoding With Joseph

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:
212.0

Do NOT write a main function.

Expected Output:

212.0
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.