mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Cleaned up a code example comment
This commit is contained in:
parent
373765b827
commit
b38d065e45
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user