Encapsulation usually hides private data. However, in embedded systems, a "Hardware Monitor" or "Debug Console" often needs to inspect the raw internal state of a peripheral driver for diagnostics, even if that state is hidden from normal application code.
Your task is to implement a class TemperatureSensor.
int raw_adc_value (initialized to 0).update(int val) to simulate a sensor reading (sets raw_adc_value).void debugMonitor(const TemperatureSensor& s).Debug: Raw ADC = <value>.friend.Program Flow:
N.N times.cmd.cmd is "READ": Read integer val, update sensor.cmd is "DEBUG": Call the global debugMonitor function with the sensor object.Input Format:
N (1 to 20).N lines: String cmd ("READ", "DEBUG").Output Format:
Debug: Raw ADC = <value>Example: Example 1
Input:
3
READ 1024
DEBUG
READ 2048Output:
Debug: Raw ADC = 1024Constraints:
raw_adc_value must be private.debugMonitor must be a standalone function (not inside the class).friend keyword.
Input
3 READ 1024 DEBUG READ 2048
Expected Output
Debug: Raw ADC = 1024