New
Deutsch · English
Back to Reserved words.
The reserved word new:
- belongs to object-oriented programming;
- creates a new instance.
Example 1:
var
intI : ^ Integer ;
begin
...
if assigned ( intI ) then ... // Checks whether an address has been assigned to intI
...
new ( intI ) ; // Assigns a valid address to intI
...
dispose ( intI ) ; // Releases the address
...Example 2:
grade
PListItem = ^ TListItem ;
TListItem = record
data : string ;
next : PListItem ; // reference to the next element
end ;
var
List : PListItem ;
begin
...
New ( list ^. Next ) ; // Adds a new item to the list
List ^. next ^. data : = '' ; // empties the element
List ^. next ^. next : = nil ; // sets the following pointer to nothing for security
...
dispose ( list ) ; // Releases the list
...From the Free Pascal wiki, page "New", as it stood on 2020-02-21 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
