← Back to Inheritance
Question 133
Using Protected Instead of Private
Using Protected Instead of Private
A base class BankAccount has been provided with a protected int accountNumber and a constructor that initializes it. A derived class CheckingAccount publicly inherits from BankAccount. ThedisplayAccount()function has been declared. Your task is to implementdisplayAccount()so that it prints: Account: [accountNumber] Because accountNumber is protected (not private), it can be accessed directly in the derived class. Do NOT include a main function. Your code will be tested automatically.
Expected Output:
Account: 12345= newline. The output ends with a newline — 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.