-
Private inheritance means is-implemented-in-terms of. It's usually inferior to composition, but it makes sense when a derived class needs access to protected base class members or needs to redefine inherited virtual functions.
-
Unlike composition, private inheritance can enable the empty base optimization. This can be important for library developers who strive to minimize object sizes.
Item 39: Use private inheritance judiciously(Effective C++)
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Item 40: Use multiple inheritance judiciously(Effective C++)
下一篇:Item 38: Model "has-a" or "is-implemented-in-terms-of" through composition(Effective C++)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章