effective c++
Item-42 Understand the two meanings of typename
· β˜• 4 min read

When declaring template parameters, both class and typename are interchangeable. When identifying nested dependent type names, use typename, except in base class lists or as a base class identifier in a member initialization list.


Item-41 Understand inplicit interfaces and compile time polymorphism
· β˜• 4 min read

Classes support explicit interfaces based on function signatures, as well as runtime polymorphism through virtual functions; templates support implicit interfaces based on valid expressions, as well as compile-time polymorphism through template instantiation and function overloading resolution.


Item-40 Use multiple inheritance judiciously
· β˜• 6 min read

Being more complex than single inheritance, Multiple inheritance (MI) can lead to ambiguity issues and to the need for virtual inheritance, the latter of which imposes costs in size, speed, and complexity of initialization and assignment, so it’s more practical to make “empty” virtual base classes.


Item-39 Use private inheritance judiciously
· β˜• 6 min read

Private inheritance means is-implemented-in-terms-of. It is usually inferior to composition, but it makes sense when a derived class needs access to protected base members or needs to redefine inherited virtual functions. For library developers who strive to minimize object sizes, it also offers the ability of empty base optimization.