Your task is to define two classes:
variable id (type int)
DerivedDevice (inherits from BaseDevice)
setId(int v)
printId()
The program will:
Example
Output:
Device ID: 101
Why this output?
Because id is protected, it’s not visible to main(), but the derived class can access it.
Question Significance
Shows how protected members can’t be touched outside but are visible in derived classes.
Test Cases
Test Results
Input
Expected Output