You are given a firmware-style driver design where different hardware drivers must be selected at runtime but accessed through a common base-class pointer.
The program currently compiles and runs, but it always executes the base driver behavior, regardless of which concrete driver is selected.
Your task is to correct the class design so that the appropriate derived driver behavior executes at runtime, while still invoking the function through a base-class pointer.
The final solution must demonstrate true runtime polymorphism using Embedded C++ principles.
Input / Program Flow
Driver selection rules:
0 → select the SPI driver1 → select the I2C driverProgram flow:
Output
If input is 0, the program must print:
SPI driver started
If input is 1, the program must print:
I2C driver started
Output Requirements
Constraints
Input
0
Expected Output
SPI driver started