When to use C++ private inheritance over composition?

Scott Meyers in “Effective C++” item 42 says

“Only inheritance gives access to protected members, and only inheritance allows for virtual functions to be redefined. Because virtual functions and protected members exist, private inheritance is sometimes the only practical way to express an is-implemented-in-terms-of relationship between
classes.”

Leave a Comment