Chapter 26. Multiple Inheritance and the Siamese Twin Problem
Difficulty: 4
Overriding inherited virtual functions is easy, as long as you're not trying to override a virtual function that has the same signature in two base classes. This can happen even when the base classes don't come from different vendors! What's the best way to separate such “Siamese Twin” functions?
Consider the following two classes:
class BaseA { virtual int ReadBuf( const char* ); // ... }; class BaseB { virtual int ReadBuf( const char* ); // ... };
Both BaseA
and BaseB
are clearly intended to be used as base classes, but they are otherwise unrelated. Their ReadBuf()
functions are intended to do different things, and the classes come from different library vendors.
Demonstrate ...
Get More Exceptional C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.