CJCoding With Joseph
15per day

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

Expected Output:

C++ Primer
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.