1. LED Class

#include <iostream>
using namespace std;

class LED {
public:
    void turnOn()  { cout << "LED ON\n";  }
    void turnOff() { cout << "LED OFF\n"; }
};

int main() {
    LED led;
    led.turnOn();
    led.turnOff();
    return 0;
}

Solution Explanation

  • We defined two public methods.
  • turnOn() prints the “on” message, turnOff() prints the “off” message.

     

Layman’s Terms

Think of LED like a remote with two buttons. Press one button: it prints “LED ON.” Press the other: “LED OFF.”

Significance for Embedded Developers

In real firmware, you’d map these methods to set/clear a GPIO pin. You’ll meet this pattern when writing simple HAL wrappers (e.g., gpio_set(pin), gpio_clear(pin)) or when structuring board support packages so app code stays readable and safe.

Loading...

Input

Expected Output

LED ON LED OFF