← Back to Inheritance
Question 135
Private Members and Getters
Private Members and Getters
A base class Book has been provided with a private string title, a constructor, and a public gettergetTitle(). A derived class EBook publicly inherits from Book. TheprintTitle()function has been declared. Your task is to implementprintTitle(). Since title is private in the base class, you CANNOT access it directly. You must use the public gettergetTitle()instead. This question teaches the difference between private and protected: private members are not accessible in derived classes, but protected members are. Do NOT include a main function. Your code will be tested automatically.
Expected Output:
C++ Primer= 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.