Protected Inheritance Access
mediumQuestion 443With protected inheritance, the base class's PUBLIC members become PROTECTED in the derived class: outside code can no longer call them, but the derived class's own methods still can.
Base class Base (already written) has a public int value() const returning 42.
Create a class Middle that inherits from Base using PROTECTED inheritance, and add a public method int reveal() const that returns value().
Outside code cannot call value() on a Middle, but reveal() can. The program prints the output shown in Expected Output.
Do NOT write a main function.
Expected output
42= newline. The output ends with a newline, so print one after the last line.
Hints3 available
Sign in to use hintsTopics
Inheritance
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.