Question.3
A state machine uses an array of function pointers:
using Handler = void (*)();
void idle() { /* ... */ }
void run() { /* ... */ }
void fault() { /* ... */ }
Handler state_table[] = { idle, run, fault };
int current = 1;
state_table[current](); // Execute current stateWhat is the advantage over a switch-case?