You are given a firmware-style driver framework with a common base driver interface and two derived drivers:
A driver object is created at runtime based on input and destroyed through a base-class pointer.
The program compiles and runs, but the shutdown sequence is incorrect:
part of the driver-specific cleanup logic is not executed.
Your task is to correct the class design so that the shutdown sequence is complete and correct for all driver types.
Input / Program Flow:
One integer value is read from standard input.
Input meaning:
0 → Create SPI driver1 → Create I2C driverProgram flow:
Output:
If input is 0, the program must print exactly:
SPI driver shutdown
Base driver shutdown
If input is 1, the program must print exactly:
I2C driver shutdown
Base driver shutdown
Output requirements:
Constraints:
Input
0
Expected Output
SPI driver shutdown Base driver shutdown