Item 34: Differentiate between inheritance of interface and inheritance of implementation(Effective C++) C++ Inheritance of interface is different from inheritance of implementation. Under public inheritance, derived classes always inherit base class interfaces. Pure virtual functions specify inheritance of int...
1. 成员函数的接口总是被继承. 如 Item32 所说, public 意味着 is-a, 所以对 base class 为真的任何事情对 derived class 也为真 2. 声明一个 pure virtual 函数的目的是为了让 derived class 只继承其接口 但令人意外的是, 我们竟然可以为 pure virtual 函数提供定义. 这有另一种用处, 即作为 default ...
The seemingly straightforward notion of (public) inheritance turns out, upon closer examination, to be composed of two separable parts: inheritance of function interfaces and inheritance of function implementations. Consider a class: classShape {public:virtualvoiddraw()const=0;virtualvoiderror(conststd:...