Article 7: Declaring virtual destructors for polymorphic base classes
1. When a base class pointer accepts the address of a derived class object, the pointer is delete, releasing only the base class part
2, to all classes with the virtual destructor is a bad idea, will have vptr point to a function pointer array, expand the unnecessary object size, unless the compensation vptr, otherwise there is no portability.
3, the String class and the STL does not contain the virtual destructor, however some users use them as the base class, using Delete to point to the base class pointer of the derived class, causing the error "c++11 added forbidden derivation nature", they are not suitable when the base class.
4, there is no suitable pure virtual function at hand, but you do need an abstract class, it is good to declare the destructor as pure virtual function, including the problem of virtual destruction, but you should remember to give him a definition, because it will be used when a destructor is derived from the class.
5. Virtual destruction is designed to handle derived class objects through a base class interface
6, some classes are to do the base class but not to support polymorphism.
7. Classes with polymorphic properties or classes with virtual functions should have virtual destructors, not for polymorphic categories with virtual destructors.
Article 8: Don't let an exception escape destructor "Review exception"
1, do not let the imaginary function throws an exception, destructors to catch any exceptions, swallow or end the program.
2. If the customer needs to react to an exception thrown during an operation, then CLSS should provide a normal function (rather than a destructor) to perform the operation
3. For resource management classes, set up a resource management class to manage objects as members, and provide functions for managing objects in the new class.
Article 9: Never invoke the virtual function "review" in the construction and destructor
1. In summary, do not use virtual functions in destructors and constructors, because the hierarchy of objects is different from the hierarchy of calls.
2. Use a static function to call the formal parameter to pass the data to the base class.
Effective C + + study notes clause 8-10