diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 4b14ebf..c0f43d6 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -4923,7 +4923,7 @@ See [this in the Discussion section](#Sd-dtor). ##### Example, bad - struct Base { // BAD: no virtual destructor + struct Base { // BAD: implicitly has a public nonvirtual destructor virtual void f(); }; @@ -4946,7 +4946,7 @@ If the interface allows destroying, it should be safe to do so. ##### Note -A destructor must be nonprivate or it will prevent using the type : +A destructor must be nonprivate or it will prevent using the type: class X { ~X(); // private destructor @@ -4963,6 +4963,7 @@ A destructor must be nonprivate or it will prevent using the type : We can imagine one case where you could want a protected virtual destructor: When an object of a derived type (and only of such a type) should be allowed to destroy *another* object (not itself) through a pointer to base. We haven't seen such a case in practice, though. + ##### Enforcement * A class with any virtual functions should have a destructor that is either public and virtual or else protected and nonvirtual.