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