You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp/delete-operator-cpp.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Deallocates a block of memory.
11
11
12
12
## Syntax
13
13
14
-
> [`::`]`delete`*cast-expression*
14
+
> [`::`]`delete`*cast-expression*\
15
15
> [`::`]`delete []`*cast-expression*
16
16
17
17
## Remarks
@@ -26,7 +26,7 @@ delete MyDialog;
26
26
27
27
Using **delete** on a pointer to an object not allocated with **new** gives unpredictable results. You can, however, use **delete** on a pointer with the value 0. This provision means that, when **new** returns 0 on failure, deleting the result of a failed **new** operation is harmless. For more information, see [The new and delete Operators](../cpp/new-and-delete-operators.md).
28
28
29
-
The **new** and **delete** operators can also be used for built-in types, including arrays. If `pointer` refers to an array, place empty brackets before `pointer`:
29
+
The **new** and **delete** operators can also be used for built-in types, including arrays. If `pointer` refers to an array, place empty brackets (`[]`) before `pointer`:
30
30
31
31
```cpp
32
32
int* set = newint[100];
@@ -80,10 +80,10 @@ For examples of using **delete**, see [new operator](../cpp/new-operator-cpp.md)
80
80
81
81
The delete operator invokes the function **operator delete**.
82
82
83
-
For objects not of class type ([class](../cpp/class-cpp.md), [struct](../cpp/struct-cpp.md), or [union](../cpp/unions.md)), the global delete operator is invoked. For objects of class type, the name of the deallocation function is resolved in global scope if the delete expression begins with the unary scope resolution operator (::). Otherwise, the delete operator invokes the destructor for an object prior to deallocating memory (if the pointer is not null). The delete operator can be defined on a per-class basis; if there is no such definition for a given class, the global operator delete is invoked. If the delete expression is used to deallocate a class object whose static type has a virtual destructor, the deallocation function is resolved through the virtual destructor of the dynamic type of the object.
83
+
For objects not of class type ([class](../cpp/class-cpp.md), [struct](../cpp/struct-cpp.md), or [union](../cpp/unions.md)), the global delete operator is invoked. For objects of class type, the name of the deallocation function is resolved in global scope if the delete expression begins with the unary scope resolution operator (`::`). Otherwise, the delete operator invokes the destructor for an object prior to deallocating memory (if the pointer is not null). The delete operator can be defined on a per-class basis; if there is no such definition for a given class, the global operator delete is invoked. If the delete expression is used to deallocate a class object whose static type has a virtual destructor, the deallocation function is resolved through the virtual destructor of the dynamic type of the object.
84
84
85
85
## See also
86
86
87
-
[Expressions with Unary Operators](../cpp/expressions-with-unary-operators.md)<br/>
88
-
[Keywords](../cpp/keywords-cpp.md)<br/>
87
+
[Expressions with Unary Operators](../cpp/expressions-with-unary-operators.md)\
88
+
[Keywords](../cpp/keywords-cpp.md)\
89
89
[new and delete Operators](../cpp/new-and-delete-operators.md)
0 commit comments