mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
Cleaned up a code example comment
This commit is contained in:
@@ -4923,7 +4923,7 @@ See [this in the Discussion section](#Sd-dtor).
|
|||||||
|
|
||||||
##### Example, bad
|
##### Example, bad
|
||||||
|
|
||||||
struct Base { // BAD: no virtual destructor
|
struct Base { // BAD: implicitly has a public nonvirtual destructor
|
||||||
virtual void f();
|
virtual void f();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4946,7 +4946,7 @@ If the interface allows destroying, it should be safe to do so.
|
|||||||
|
|
||||||
##### Note
|
##### 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 {
|
class X {
|
||||||
~X(); // private destructor
|
~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.
|
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
|
##### Enforcement
|
||||||
|
|
||||||
* A class with any virtual functions should have a destructor that is either public and virtual or else protected and nonvirtual.
|
* A class with any virtual functions should have a destructor that is either public and virtual or else protected and nonvirtual.
|
||||||
|
|||||||
Reference in New Issue
Block a user