C++ enforces access control using private, protected, and public at compile time. In embedded and firmware development, this is critical for preventing unsafe or unintended access to internal driver state.
You are given a small driver-style class hierarchy consisting of:
BaseDriver)DerivedDriver)The provided program does not compile initially because it attempts to access class members in ways that violate C++ access rules.
Your task is to make the program compile by fixing only the illegal access statements, while keeping the original class design intact. This exercise focuses purely on understanding and enforcing C++ access control rules as they apply to embedded-style class hierarchies.
Rules (Strict)
You must follow all rules below:
Any violation of these rules results in an invalid solution.
Input
Three integers read from standard input:
val1 val2 val3
These values are used to initialize the base class member variables via the constructor.
Example Input
1 2 3
Program Flow (Mandatory)
Your program must execute in the exact order below:
DerivedDriver objectfunction1() (base class function)function2() (derived class function)main()The order of execution must not be changed.
Output
cout statements may produce output
Constraints
cout statements
Input
1 2 3
Expected Output
function1 privateValue = 1 function1 protectedValue = 2 function1 publicValue = 3 function2 protectedValue = 2 function2 publicValue = 3 main() publicValue = 3