Compound methods (composition) and private inheritance can all represent the form of a new class implemented from a class, by using protected members, and by overriding the virtual function.
Choose the compound method preferentially. Reason:
1. The compound method can be implemented to override the virtual function and then prevent the derived class from redefining the virtual function;
2. You can minimize the compilation dependency of a widget by containing only the declarations (comps) of the class and avoiding the header file (inheritance) that contains the base class;
Exception: Private inheritance, which makes Ebo (the most optimized for whitespace base classes), is important in the case of some whitespace base classes, but rarely occurs. So the first compound.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/cplus/