#include <iostream> using namespace std; class PowerControl { public: void enable() { cout << "Power enabled" << endl; } }; class InterruptControl { public: void enable() { cout << "Interrupt enabled" << endl; } }; // Multiple inheritance class SpiDriver : public PowerControl, public InterruptControl { }; int main() { int mode; cin >> mode; SpiDriver spi; if (mode == 0) { spi.PowerControl::enable(); // Explicitly select PowerControl } else if (mode == 1) { spi.InterruptControl::enable(); // Explicitly select InterruptControl } return 0; }
Test Cases
Test Results
Input
0
Expected Output
Power enabled