CJCoding With Joseph
15free / daySign inCreate account

Private Members and Getters

A base class Book has been provided with a private string title, a constructor, and a public getter getTitle().

A derived class EBook publicly inherits from Book. The printTitle() function has been declared.

Your task is to implement printTitle(). Since title is private in the base class, you CANNOT access it directly. You must use the public getter getTitle() 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
Topics:
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.