#include <iostream>
#include <string>
using namespace std;
void onPressA() { cout << "Button A pressed\n"; }
void onPressB() { cout << "Button B pressed\n"; }
void simulatePress(void (*callback)()) {
    callback(); // call the function passed in
}
int main() {
    string input;
    cin >> input;
    if (input == "A") {
        simulatePress(onPressA);
    } else if (input == "B") {
        simulatePress(onPressB);
    }
    return 0; }
Solution Details
👉 In simple words:
 Think of the button as a doorbell. The callback is who answers the door. You can change who answers without changing the doorbell itself.
Significance for Embedded Developers
Input
A
Expected Output
Button A pressed