Reread STL source code analysis: Destructor

Pure virtual destructor

In theory, the function is declared after a pure virtual function, namely the class becomes abstract class. Pure virtual function provides only the interface, without providing achieved, but the pure virtual destructor must provide definitions. This is determined by the C ++ features, the compiler destructor derived class may be extended in the manner called statically call each of the virtual base class, and the destructor base class, despite being an abstract class, but still to provide an implementation for the pure virtual destructor, even awov :: ~ awov () {} does not implement any such operation, because if not available, will cause the link to fail

Virtual function inlining

Inline function is a static behavior, launched by the compiler at the call site, this is done at compile time; and virtual function is a dynamic behavior, it is done at runtime by the virtual function table jump, so inline and virtual are contradictory, the reason for the virtual declaration of inline functions can be run successfully, it is because the compiler is optimized. inline is a suggestion to the compiler, and the compiler whether to adopt may not. j

Guess you like

Origin www.cnblogs.com/lxy-xf/p/11515570.html