From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/CPLUSPLUS/SYNTAX/delete.html | 111 +++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 reference/CPLUSPLUS/SYNTAX/delete.html (limited to 'reference/CPLUSPLUS/SYNTAX/delete.html') diff --git a/reference/CPLUSPLUS/SYNTAX/delete.html b/reference/CPLUSPLUS/SYNTAX/delete.html new file mode 100644 index 0000000..224c487 --- /dev/null +++ b/reference/CPLUSPLUS/SYNTAX/delete.html @@ -0,0 +1,111 @@ +DELETE keyword + + + +
+

DELETE keyword

+
+

+The delete keyword replaces the +free +function in C and will release storage reserved with +new. + +

+

+ + + + +
+
+
+    int *ptr1;                  // Declare a pointer to int.
+    ptr1 = new int;             // Reserve storage and point to it.
+    
+    float *ptr2 = new float;    // Do it all in one statement.
+    
+    delete ptr1;                // Free the storage.
+    delete ptr2;
+    
+    struct House                // Declare a complex structure.
+    {
+        int Floors;
+        int Windows;
+    };
+    
+    House *ptr3 = new House;    // Reserve storage and point to it.
+
+    delete ptr3;
+
+
+
+

+ +Blocks or arrays of storage can also be freed as shown in the +next example. + +

+

+ + + + +
+
+
+    char *ptr
+    ptr = new char[80];
+    
+    delete [] ptr;          // Free the storage.
+
+
+
+

+ + +


+

Examples:

+o +Example program. +
+

See Also:

+o +new keyword. + +
+ +

C References

+

+o +malloc function. + +

+o +free function. + + +


+

+

+ + + + +
+Top + +Master Index + +C++ Keywords + +Functions +
+
+

+


+ +
Martin Leslie +17-Feb-96

+ + -- cgit v1.2.3-54-g00ecf