Skip to main content

Practice · 1 of 1

A const-correct thermometer

Implement struct Thermometer with a private double celsius_{0.0};, void set(double c) storing the value, double celsius() const returning it, and double fahrenheit() const returning celsius() * 9.0 / 5.0 + 32.0. Both getters must be const.

Difficulty: intermediate

Back to lesson: Practice: Design a const-correct type