#include <iostream>
using namespace std;
// Motor driver A
namespace DriverA {
void init() {
cout << "A INIT";
}
}
// Motor driver B
namespace DriverB {
void init() {
cout << "B INIT";
}
}
int main() {
int x;
cin >> x;
if (x == 1) {
DriverA::init(); // call driver A
}
else if (x == 2) {
DriverB::init(); // call driver B
}
return 0;
}
Explanation & Logic Summary:
init()DriverA::init() and DriverB::init() explicitly select the correct driverFirmware Relevance & Real-World Context:
Embedded projects often include:
init, start, read, etc.)Namespaces prevent conflicts when integrating multiple codebases.
This is especially important in large embedded systems or when mixing vendor SDKs with custom drivers.
Input
1
Expected Output
A INIT