#include <iostream>
using namespace std;
// Base driver class
class BaseDriver {
public:
void configure(int value) {
cout << "Base configuration value " << value << endl;
}
};
// Derived driver class
class DerivedDriver : public BaseDriver {
public:
using BaseDriver::configure; // Restore base class overload
void configure() {
cout << "Derived default configuration" << endl;
}
};
int main() {
int value;
cin >> value;
DerivedDriver driver;
driver.configure(); // Derived version
driver.configure(value); // Base version
return 0;
}
Explanation & Logic Summary:
When a derived class defines a function with the same name as a base class function, all base class overloads with that name are hidden.
The statement:
using BaseDriver::configure;
explicitly brings the base class function back into the derived class scope, allowing both overloads to coexist and be called on the same object.
Firmware Relevance & Real-World Context:
In real embedded firmware:
Failing to address this can lead to:
Understanding and resolving name hiding is essential for building safe, extensible, and maintainable embedded driver hierarchies.
Input
8
Expected Output
Derived default configuration Base configuration value 8