Code Room
Code reviewMedium
Question
Review this C++ class. The default constructor leaves a field unset on one path.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
class Sensor { int id_; double calib_; // calibration factorpublic: Sensor(int id) : id_(id) { if (id < 0) calib_ = 0.0; // sentinel for invalid // valid ids: calib_ left for loadCalibration() } double read(double raw) const { return raw * calib_; }};Run or narrate your approach, then ask the coach.