#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; // Fix ambiguity and call correct enable() based on mode (mode == 0) ? spi.PowerControl::enable() : spi.InterruptControl::enable(); return 0; }
Test Cases
Test Results
Input
0
Expected Output
Power enabled