Chapter 20, Removing Implementation Details Using the pImpl Pattern
- Please see
Assessments/Chapter20/Chp20-Q1.cpp
in the GitHub repository. - Please see
Assessments/Chapter20/Chp20-Q2.cpp
in the GitHub repository.
(follow-up question) In this chapter, simply inheriting Student
from the Person
class that embraces the pImpl pattern presents no logistical difficulties. Additionally, modifying the Student
class to also employ the pImpl pattern and utilize a unique pointer is more challenging. Various approaches may run across various difficulties, including dealing with inline functions, down-casting, avoiding explicit calls to the underlying implementation, or requiring back pointers to help invoke virtual functions. Please see the online solution for details.
- Other examples which may easily incorporate the pImpl pattern for relative implementation independence include creating generic GUI components, such as for
Window
,Scrollbar
,Textbox
, and so on, for various...