#include <iostream>
// Overload for modification
void process(int& x) {
x = x * 2;
}
// Overload for read-only use
void process(const int& x) {
std::cout << "readonly";
}
int main() {
int x;
std::cin >> x;
if (x < 0) {
process(static_cast<const int&>(x)); // read-only
} else {
process(x); // modification
std::cout << x;
}
return 0;
}
Explanation & Logic Summary:
Firmware Relevance & Real-World Context:
Input
5
Expected Output
10