Protected Helper Method
easyQuestion 433A protected method can be called by a derived class but not from outside the hierarchy.
Base class Calculator (already written) has a PROTECTED method int square(int x) const returning x * x.
Create a derived class StatsCalculator with a PUBLIC method int squarePlusOne(int x) const that returns square(x) + 1 by calling the inherited protected helper.
For input 5, square(5) is 25 and the result is 26, so the program prints the output shown in Expected Output.
Do NOT write a main function.
Expected output
26= newline. The output ends with a newline, so print one after the last line.
Hints2 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.