diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2008-01-27 11:37:44 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2008-01-27 11:37:44 +0100 |
commit | 7e0f021a9aec35fd8e6725e87e3313b101d26f5e (patch) | |
tree | b1cacc4b24393f517aeb4610e9e1021f954307a8 /reference/CPLUSPLUS/SYNTAX/delete.html |
Initial import (2.0.2-6)2.0.2-6
Diffstat (limited to 'reference/CPLUSPLUS/SYNTAX/delete.html')
-rw-r--r-- | reference/CPLUSPLUS/SYNTAX/delete.html | 111 |
1 files changed, 111 insertions, 0 deletions
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 @@ +<title>DELETE keyword</title> +<!-- Changed by: Martin Leslie, 14-Mar-1996 --> +<body bgcolor="#dddddd"> +<font color=brown> +<hr> +<center><h1>DELETE keyword</h1></center> +<hr> +<p> +The <b>delete</b> keyword replaces the +<a href="../../C/FUNCTIONS/free.html">free</a> +function in C and will release storage reserved with +<a href="new.html">new</a>. + +<p> +<center> +<table bgcolor=ivory width="80%" border=1> +<tr> +<td> +<pre> + + 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. + + <b>delete</b> ptr1; // Free the storage. + <b>delete</b> ptr2; + + struct House // Declare a complex structure. + { + int Floors; + int Windows; + }; + + House *ptr3 = new House; // Reserve storage and point to it. + + <b>delete</b> ptr3; +</pre> +</td> +</tr> +</table> +</center> +<p> + +Blocks or arrays of storage can also be freed as shown in the +next example. + +<p> +<center> +<table bgcolor=ivory width="80%" border=1> +<tr> +<td> +<pre> + + char *ptr + ptr = new char[80]; + + <b>delete</b> [] ptr; // Free the storage. +</pre> +</td> +</tr> +</table> +</center> +<p> + + +<hr> +<h2>Examples:</h2> +<img src="../../GRAPHICS/computer.gif" alt="o"> +<a href="..//EXAMPLES/new.cc">Example program.</a> +<hr> +<h2>See Also:</h2> +<img src="../../GRAPHICS/whiteball.gif" alt="o"> +<a href="new.html">new</a> keyword. + +</font> +<font color=black> +<h2>C References</h2> +<p> +<img src="../../GRAPHICS/whiteball.gif" alt="o"> +<a href="../../C/FUNCTIONS/malloc.html">malloc</a> function. + +<p> +<img src="../../GRAPHICS/whiteball.gif" alt="o"> +<a href="../../C/FUNCTIONS/free.html">free</a> function. +</font> + +<hr> +<p> +<center> +<table border=2 width="80%" bgcolor="ivory"> +<tr align=center> +<td width="25%"> +<a href="../cref.html">Top</a> +</td><td width="25%"> +<a href="../../C/master_index.html">Master Index</a> +</td><td width="25%"> +<a href="keywords.html">C++ Keywords</a> +</td><td width="25%"> +<a href="../../C/FUNCTIONS/funcref.htm">Functions</a> +</td> +</tr> +</table> +</center> +<p> +<hr> +<font color=brown> +<address>Martin Leslie +17-Feb-96</address><p> +</font> + |