Revision history for KeyPgOpDelete


Revision [22445]

Last edited on 2018-08-30 02:23:21 by fxm [Page updated while 'Operator Delete Overload' page creation]
Additions:
The memory deallocation process part provided by the ##**Delete Statement**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpDeleteOverload|Delete Overload]]##. The previous process part for data destruction can never be modified.
Deletions:
The memory deallocation process provided by the ##**Delete Statement**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpDeleteOverload|Delete Overload]]##. The previous process of data destruction can never be modified.


Revision [22439]

Edited on 2018-08-29 16:08:05 by fxm [Page updated while 'Operator Delete Overload' page creation]
Additions:
Calling ##**Delete Statement**## operator on a null pointer induces no action.
Deletions:
Calling ##**Delete Statement**## on a null pointer induces no action.


Revision [22434]

Edited on 2018-08-29 13:28:34 by fxm [Page updated while 'Operator Delete Overload' page creation]
Additions:
Operator to destroy data and free memory allocated with the ##[[KeyPgOpNew|Operator New Expression]]##
Deletions:
Operator to delete data allocated with the ##[[KeyPgOpNew|Operator New Expression]]##


Revision [22433]

Edited on 2018-08-29 13:16:21 by fxm [Page updated while 'Operator Delete Overload' page creation]
Additions:
The memory deallocation process provided by the ##**Delete Statement**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpDeleteOverload|Delete Overload]]##. The previous process of data destruction can never be modified.
Deletions:
The memory deallocation process provided by the ##**Delete Statement**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpDeleteOverload|Delete Overload]]##.


Revision [22422]

Edited on 2018-08-29 08:18:28 by fxm [Page updated while 'Operator Delete Overload' page creation]
Deletions:
==={{color text="Update in progress (@fxm)." c="red"}}===


Revision [22413]

Edited on 2018-08-29 07:29:45 by fxm [Update in progress]
Additions:
The memory deallocation process provided by the ##**Delete Statement**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpDeleteOverload|Delete Overload]]##.
Deletions:
The memory deallocation process provided by the ##**Delete Statement**## operator can be overloaded for user-defined types as a member ##[[KeyPgOpDeleteOverload|Delete Overload]]## operator.


Revision [22401]

Edited on 2018-08-29 06:07:01 by fxm [Update in progress]
Additions:
##**Delete Statement**## operator must be used with addresses returned from ##[[KeyPgOpNew|New Expression]]## operator, and ##**Delete[] Statement**## operator with ##**New[] Expression**## operator, the array-version of ##[[KeyPgOpNew|New Expression]]## operator. You cannot mix and match the different versions of the operators.
After the memory is deleted, the ##//buf//## pointer will be pointing at invalid memory. Calling ##**Delete Expression**## twice on the same pointer value leads to undefined behavior. It may be a good idea to set the //##buf//## pointer to null (##0##), in order to guard against later code using it accidentally, since null pointer dereferences are easier to find and debug.
Calling ##**Delete Statement**## on a null pointer induces no action.
The memory deallocation process provided by the ##**Delete Statement**## operator can be overloaded for user-defined types as a member ##[[KeyPgOpDeleteOverload|Delete Overload]]## operator.
**Note:** Any operator ##**Delete[] Statement**## (or the only overload operator ##**Delete Statement**##) is not compatible with sub-type polymorphism, even using ##[[KeyPgOverride|Override]]## ##[[KeyPgVirtual|Virtual]]## ##[[KeyPgDestructor|Destructor]]## that may in addition induce crashing.
Instead of having to call such an operator ##**Delete([]) Statement**## on derived-type pointer, the safest way is to simply call (on base-type pointer) an overridden user ##[[KeyPgVirtual|Virtual]]## member procedure that will automatically launch the operator ##**Delete([]) Statement**## at derived-type level.
- ##[[KeyPgOpNew|New Expression]]##
- ##[[KeyPgOpDeleteOverload|Delete Overload]]##
Deletions:
##**Delete**## must be used with addresses returned from ##[[KeyPgOpNew|New]]##, and ##**Delete[]**## with ##[[KeyPgOpNew|New]][]##. You cannot mix and match the different versions of the operators.
After the memory is deleted, the ##//buf//## pointer will be pointing at invalid memory. Calling ##**Delete**## twice on the same pointer value leads to undefined behaviour. It may be a good idea to set the //##buf//## pointer to null (##0##), in order to guard against later code using it accidentally, since null pointer dereferences are easier to find and debug.
Calling ##**Delete**## on a null pointer induces no action.
This operator can be overloaded for user-defined types as a member ##[[KeyPgOperator|Operator]]##.
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with sub-type polymorphism, even using ##[[KeyPgOverride|Override]]## ##[[KeyPgVirtual|Virtual]]## ##[[KeyPgDestructor|Destructor]]## that may in addition induce crashing.
Instead of having to call such an operator ##**Delete([])**## on derived-type pointer, the safest way is to simply call (on base-type pointer) an overridden user ##[[KeyPgVirtual|Virtual]]## member procedure that will automatically launch the operator ##**Delete([])**## at derived-type level.
- ##[[KeyPgOpNew|New]]##


Revision [22400]

Edited on 2018-08-29 04:54:25 by fxm [Update in progress]
Additions:
The array version of ##**Delete Statement**## operator, ##**Delete[] Statement**## operator, is used to destroy an array of objects previously created with ##**New[] Expression**## operator, the array-version of ##[[KeyPgOpNew|New Expression]]## operator. Destructors will be called here as well.
Deletions:
The array version of ##**Delete**##, ##**Delete[]**##, is used to destroy an array of objects previously created with ##[[KeyPgOpNew|New]][]##. Destructors will be called here as well.


Revision [22399]

Edited on 2018-08-29 04:45:28 by fxm [Update in progress]
Additions:
A pointer to memory that has been allocated by ##[[KeyPgOpNew|New Expression]]## operator or ##**New[] Expression**## operator, the array-version of ##[[KeyPgOpNew|New Expression]]## operator (a typed pointer must be provided in accordance to the data type to delete).
The ##**Delete Statement**## operator is used to destroy and free the memory of an object created with ##[[KeyPgOpNew|New Expression]]## operator. When deleting a TYPE, its destructor will be called. ##**Delete Statement**## operator should only be used with addresses returned from ##[[KeyPgOpNew|New Expression]]## operator.
Deletions:
{{fbdoc item="syntax"}}##
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **delete** ( //buf// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] )
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **delete[]** ( //buf// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] )
A pointer to memory that has been allocated by ##[[KeyPgOpNew|New]]## or ##[[KeyPgOpNew|New]][]## (a typed pointer must be provided in accordance to the data type to delete).
##**Delete**## is used to destroy and free the memory of an object created with ##[[KeyPgOpNew|New]]##. When deleting a TYPE, its destructor will be called. ##**Delete**## should only be used with addresses returned from ##[[KeyPgOpNew|New]]##.


Revision [22394]

Edited on 2018-08-29 04:01:19 by fxm [Update in progress]
Additions:
Operator to delete data allocated with the ##[[KeyPgOpNew|Operator New Expression]]##
Deletions:
Operator to delete data allocated with the ##[[KeyPgOpNew|New Statement]]## operator


Revision [22393]

Edited on 2018-08-29 03:51:58 by fxm [Update in progress]
Additions:
{{fbdoc item="title" value="Operator Delete Statement"}}----
Operator to delete data allocated with the ##[[KeyPgOpNew|New Statement]]## operator
Deletions:
{{fbdoc item="title" value="Operator Delete"}}----
Operator to delete data allocated with the ##[[KeyPgOpNew|New]]## operator


Revision [22391]

Edited on 2018-08-29 03:48:34 by fxm [Update in progress]
Additions:
==={{color text="Update in progress (@fxm)." c="red"}}===


Revision [22368]

Edited on 2018-08-25 07:52:15 by fxm [Added note on incompatibility between any operator Delete[] (or the only overload operator Delete) and sub-type polymorphism]
Additions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with sub-type polymorphism, even using ##[[KeyPgOverride|Override]]## ##[[KeyPgVirtual|Virtual]]## ##[[KeyPgDestructor|Destructor]]## that may in addition induce crashing.
Deletions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with polymorphism, even using ##[[KeyPgOverride|Override]]## ##[[KeyPgVirtual|Virtual]]## ##[[KeyPgDestructor|Destructor]]## that may in addition induce crashing.


Revision [21783]

Edited on 2017-07-14 03:37:47 by fxm [Added note on incompatibility between any operator Delete[] (or the only overload operator Delete) and polymorphism]
Additions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with polymorphism, even using ##[[KeyPgOverride|Override]]## ##[[KeyPgVirtual|Virtual]]## ##[[KeyPgDestructor|Destructor]]## that may in addition induce crashing.
Deletions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with polymorphism, even using ##[[KeyPgVirtual|Virtual]]## destructors that may in addition induce crashing.


Revision [21782]

Edited on 2017-07-14 03:20:02 by fxm [Added note on incompatibility between any operator Delete[] (or the only overload operator Delete) and polymorphism]
Additions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with polymorphism, even using ##[[KeyPgVirtual|Virtual]]## destructors that may in addition induce crashing.
Instead of having to call such an operator ##**Delete([])**## on derived-type pointer, the safest way is to simply call (on base-type pointer) an overridden user ##[[KeyPgVirtual|Virtual]]## member procedure that will automatically launch the operator ##**Delete([])**## at derived-type level.
Deletions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with polymorphism, even using virtual destructors that may in addition induce crashing.
Instead of having to call such an operator ##**Delete([])**## on derived-type pointer, the safest way is to simply call (on base-type pointer) an overridden user virtual member procedure that will automatically launch the operator ##**Delete([])**## at derived-type level.


Revision [21781]

Edited on 2017-07-14 01:47:01 by fxm [Added note on incompatibility between any operator Delete[] (or the only overload operator Delete) and polymorphism]
Additions:
Instead of having to call such an operator ##**Delete([])**## on derived-type pointer, the safest way is to simply call (on base-type pointer) an overridden user virtual member procedure that will automatically launch the operator ##**Delete([])**## at derived-type level.
Deletions:
Instead of having to call such an operator ##**Delete([])**## on derived-type pointer, the safest way is to simply call (on base-type pointer) an overridden user virtual member procedure that automatically launches the operator ##**Delete([])**## at derived-type level.


Revision [21780]

Edited on 2017-07-14 00:53:53 by fxm [Added note on incompatibility between any operator Delete[] (or the only overload operator Delete) and polymorphism]
Additions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with polymorphism, even using virtual destructors that may in addition induce crashing.
Instead of having to call such an operator ##**Delete([])**## on derived-type pointer, the safest way is to simply call (on base-type pointer) an overridden user virtual member procedure that automatically launches the operator ##**Delete([])**## at derived-type level.
Deletions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with the polymorphism, even using virtual destructor that may in addition induce crashing.
Instead of being obliged to call any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) automatically at child-level.


Revision [21778]

Edited on 2017-07-09 03:25:36 by fxm [Added note on incompatibility between any operator Delete[] (or the only overload operator Delete) and polymorphism]
Additions:
**Note:** Any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with the polymorphism, even using virtual destructor that may in addition induce crashing.
Instead of being obliged to call any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches any operator ##**Delete[]**## (or the only overload operator ##**Delete**##) automatically at child-level.
Deletions:
**Note:** The operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with the polymorphism, even using virtual destructor that may in addition induce crashing.
Instead of being obliged to call the operator ##**Delete[]**## (or the only overload operator ##**Delete**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches the operator ##**Delete[]**## (or the only overload operator ##**Delete**##) automatically at child-level.


Revision [21777]

Edited on 2017-07-08 14:34:12 by fxm [Added note on incompatibility between operator Delete[] (or only overload operator Delete) and polymorphism]
Additions:
**Note:** The operator ##**Delete[]**## (or the only overload operator ##**Delete**##) is not compatible with the polymorphism, even using virtual destructor that may in addition induce crashing.
Instead of being obliged to call the operator ##**Delete[]**## (or the only overload operator ##**Delete**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches the operator ##**Delete[]**## (or the only overload operator ##**Delete**##) automatically at child-level.
Deletions:
**Note:** The operator ##**Delete[]**## (or the overload operator ##**Delete**##) is not compatible with the polymorphism, even using virtual destructor that can in addition induce crashing.
Instead of being obliged to call the operator ##**Delete[]**## (or the overload operator ##**Delete**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches the operator ##**Delete[]**## (or the overload operator ##**Delete**##) automatically at child-level.


Revision [21776]

Edited on 2017-07-08 14:15:59 by fxm [Added note on incompatibility between operator Delete[] (or overload operator Delete) and polymorphism]
Additions:
**Note:** The operator ##**Delete[]**## (or the overload operator ##**Delete**##) is not compatible with the polymorphism, even using virtual destructor that can in addition induce crashing.
Instead of being obliged to call the operator ##**Delete[]**## (or the overload operator ##**Delete**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches the operator ##**Delete[]**## (or the overload operator ##**Delete**##) automatically at child-level.
Deletions:
**Note:** The overload operator ##**Delete**## (or ##**Delete[]**##) is not compatible with the polymorphism, even using virtual destructor that can in addition induce crashing.
Instead of being obliged to call the overload operator ##**Delete**## (or ##**Delete[]**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches the operator ##**Delete**## (or ##**Delete[]**##) automatically at child-level.


Revision [21775]

Edited on 2017-07-08 13:12:04 by fxm [Added note on incompatibility between overload operator Delete (or Delete[]) and polymorphism]
Additions:
**Note:** The overload operator ##**Delete**## (or ##**Delete[]**##) is not compatible with the polymorphism, even using virtual destructor that can in addition induce crashing.
Instead of being obliged to call the overload operator ##**Delete**## (or ##**Delete[]**##) on a child-type pointer, the safest is to simply call (on the base-type pointer) a user virtual member procedure that launches the operator ##**Delete**## (or ##**Delete[]**##) automatically at child-level.


Revision [21347]

Edited on 2016-04-15 03:32:40 by fxm [Added reference to KeyPgOperator when overloaded as member operator]
Additions:
This operator can be overloaded for user-defined types as a member ##[[KeyPgOperator|Operator]]##.


Revision [21020]

Edited on 2016-03-13 05:33:25 by fxm [Formatting]
Additions:





Revision [20370]

Edited on 2016-02-10 16:04:10 by DkLwikki [Update link format]
Additions:
Operator to delete data allocated with the ##[[KeyPgOpNew|New]]## operator
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **delete** ( //buf// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] )
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **delete[]** ( //buf// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] )
A pointer to memory that has been allocated by ##[[KeyPgOpNew|New]]## or ##[[KeyPgOpNew|New]][]## (a typed pointer must be provided in accordance to the data type to delete).
##**Delete**## is used to destroy and free the memory of an object created with ##[[KeyPgOpNew|New]]##. When deleting a TYPE, its destructor will be called. ##**Delete**## should only be used with addresses returned from ##[[KeyPgOpNew|New]]##.
The array version of ##**Delete**##, ##**Delete[]**##, is used to destroy an array of objects previously created with ##[[KeyPgOpNew|New]][]##. Destructors will be called here as well.
##**Delete**## must be used with addresses returned from ##[[KeyPgOpNew|New]]##, and ##**Delete[]**## with ##[[KeyPgOpNew|New]][]##. You cannot mix and match the different versions of the operators.
- Only available in the //[[CompilerOptlang|-lang fb]]// dialect.
- ##[[KeyPgOpNew|New]]##
- ##[[KeyPgDeallocate|Deallocate]]##
Deletions:
Operator to delete data allocated with the ##[[KeyPgOpNew New]]## operator
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete** ( //buf// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] )
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete[]** ( //buf// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] )
A pointer to memory that has been allocated by ##[[KeyPgOpNew New]]## or ##[[KeyPgOpNew New]][]## (a typed pointer must be provided in accordance to the data type to delete).
##**Delete**## is used to destroy and free the memory of an object created with ##[[KeyPgOpNew New]]##. When deleting a TYPE, its destructor will be called. ##**Delete**## should only be used with addresses returned from ##[[KeyPgOpNew New]]##.
The array version of ##**Delete**##, ##**Delete[]**##, is used to destroy an array of objects previously created with ##[[KeyPgOpNew New]][]##. Destructors will be called here as well.
##**Delete**## must be used with addresses returned from ##[[KeyPgOpNew New]]##, and ##**Delete[]**## with ##[[KeyPgOpNew New]][]##. You cannot mix and match the different versions of the operators.
- Only available in the //[[CompilerOptlang -lang fb]]// dialect.
- ##[[KeyPgOpNew New]]##
- ##[[KeyPgDeallocate Deallocate]]##


Revision [17099]

Edited on 2014-06-22 04:46:26 by FxMwikki [The 'Delete' operator expects a typed pointer]
Additions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete** ( //buf// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] )
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete[]** ( //buf// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] )
A pointer to memory that has been allocated by ##[[KeyPgOpNew New]]## or ##[[KeyPgOpNew New]][]## (a typed pointer must be provided in accordance to the data type to delete).
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete** ( //buf// [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]] )
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete[]** ( //buf// [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]] )
A pointer (of type ##[[DataType datatype]]##) to memory that has been allocated by ##[[KeyPgOpNew New]]## or ##[[KeyPgOpNew New]][]##.


Revision [17097]

Edited on 2014-06-21 13:42:02 by FxMwikki [The 'Delete' operator expects a typed pointer]
Additions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete** ( //buf// [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]] )
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete[]** ( //buf// [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]] )
A pointer (of type ##[[DataType datatype]]##) to memory that has been allocated by ##[[KeyPgOpNew New]]## or ##[[KeyPgOpNew New]][]##.
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete** ( //buf// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] )
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **delete[]** ( //buf// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] )
A pointer to memory that has been allocated by ##[[KeyPgOpNew New]]## or ##[[KeyPgOpNew New]][]##.


Revision [17011]

Edited on 2014-03-09 15:09:24 by FxMwikki [Added some details]
Additions:
After the memory is deleted, the ##//buf//## pointer will be pointing at invalid memory. Calling ##**Delete**## twice on the same pointer value leads to undefined behaviour. It may be a good idea to set the //##buf//## pointer to null (##0##), in order to guard against later code using it accidentally, since null pointer dereferences are easier to find and debug.
Calling ##**Delete**## on a null pointer induces no action.
Deletions:
After the memory is deleted, the ##//buf//## pointer will be pointing at invalid memory. It may be a good idea to set the //##buf//## pointer to null (##0##), in order to guard against later code using it accidentally, since null pointer dereferences are easier to find and debug.


Revision [16722]

Edited on 2013-04-19 11:53:50 by CountingPine [Added some details]
Additions:
After the memory is deleted, the ##//buf//## pointer will be pointing at invalid memory. It may be a good idea to set the //##buf//## pointer to null (##0##), in order to guard against later code using it accidentally, since null pointer dereferences are easier to find and debug.
Deletions:
After the memory is deleted, the ##//buf//## pointer will be pointing at invalid memory. It may be a good idea to set the //##buf//## pointer to null (##0##), in order to guard against later code using it accidentally, since null pointer dereferences are easier to find debug.


Revision [16721]

Edited on 2013-04-19 11:53:09 by CountingPine [Formatting, separate examples and remove scopes, clarify some points, recommend setting ptr to 0]
Additions:
**Delete** //buf//
**Delete[]** //buf//
A pointer to memory that has been allocated by ##[[KeyPgOpNew New]]## or ##[[KeyPgOpNew New]][]##.
##**Delete**## is used to destroy and free the memory of an object created with ##[[KeyPgOpNew New]]##. When deleting a TYPE, its destructor will be called. ##**Delete**## should only be used with addresses returned from ##[[KeyPgOpNew New]]##.
The array version of ##**Delete**##, ##**Delete[]**##, is used to destroy an array of objects previously created with ##[[KeyPgOpNew New]][]##. Destructors will be called here as well.
##**Delete**## must be used with addresses returned from ##[[KeyPgOpNew New]]##, and ##**Delete[]**## with ##[[KeyPgOpNew New]][]##. You cannot mix and match the different versions of the operators.
After the memory is deleted, the ##//buf//## pointer will be pointing at invalid memory. It may be a good idea to set the //##buf//## pointer to null (##0##), in order to guard against later code using it accidentally, since null pointer dereferences are easier to find debug.
as integer numerator, denominator
' Create and initialize a Rational, and store its address.
dim p as Rational ptr = new Rational(3, 4)
print p->numerator & "/" & p->denominator
' Destroy the rational and give its memory back to the system.
delete p
' Set the pointer to null to guard against future accesses
p = 0
{{fbdoc item="filename" value="examples/manual/operator/delete2.bas"}}%%(freebasic)
' Allocate memory for 100 integers, store the address of the first one.
dim p as integer ptr = new integer[100]
' Assign some values to the integers in the array.
for i as integer = 0 to 99
p[i] = i
next
' Free the entire integer array.
delete[] p
' Set the pointer to null to guard against future accesses
p = 0
- ##[[KeyPgDeallocate Deallocate]]##
Deletions:
**Delete** //expression//
**Delete[]** //expression//
An address of memory to free.
##//expression//##
An address of memory to free.
##**Delete**## is used to destroy and free the memory of an object created with [[KeyPgOpNew New]]. When deleting a TYPE, its destructor will be called. ##**Delete**## should only be used with addresses returned from ##[[KeyPgOpNew New]]##.
The array version of ##**Delete**##, ##**Delete[]**##, is used to destroy an array of objects previously created with [[KeyPgOpNew New]][]. Destructors will be called here as well.
##**Delete**## must be used with addresses returned from [[KeyPgOpNew New]], and ##**Delete[]**## with [[KeyPgOpNew New]][]. You cannot mix and match the different versions of the operators.
as integer numerator, denominator
scope
' Create and initialize a Rational, and store its address.
dim p as Rational ptr = new Rational(3, 4)
print p->numerator & "/" & p->denominator
' Destroy the rational and give its memory back to the system.
delete p
end scope
scope
' Allocate memory for 100 integers, store the address of the first one.
dim p as integer ptr = new integer[100]
' Assign some values to the integers in the array.
for i as integer = 0 to 99
p[i] = i
next
' Free the entire integer array.
delete[] p
end scope


Revision [16257]

Edited on 2012-08-11 19:29:08 by CountingPine [it's -> its]
Additions:
' Create and initialize a Rational, and store its address.
Deletions:
' Create and initialize a Rational, and store it's address.


Revision [14392]

Edited on 2009-08-29 21:55:31 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [12559]

The oldest known version of this page was created on 2008-02-13 08:04:47 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode