#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
The LED class has two public functions.
The object led is declared in main().
Using led.turnOn() and led.turnOff(), the program prints both lines.
Layman’s Terms
The object is like a remote control. You press one button (turnOn) and it prints "LED ON". Press another (turnOff) and it prints "LED OFF".
Significance for Embedded Developers
This is exactly how you’d model GPIO control in firmware: you call high-level functions (turnOn(), turnOff()) instead of manually writing to registers.