|
|
Type declarationsPointer typesPointer types have values that are memory addresses. A pointer type is bound to a specific object type, so the value of the pointer is the address of an object of a specific type. To specify pointer types, use: POINTER TO TypeName Example: POINTER TO CHAR The constant NIL is compatible with all pointer types, and designates a pointer that does not point to any object. NIL can be assigned to any pointer type, and any pointer type can be compared to NIL. Allocating pointersGenerally, pointers are set by allocating a block of memory for the object that they point to. The NEW standard procedure and the ALLOCATE procedure in the ISO module Storage performs this function. You can deallocate the memory with the DISPOSE standard procedure, or the DEALLOCATE procedure. The ALLOCATE and DEALLOCATE procedures are exported from the ISO module Storage. Dereferencing pointersDereferencing is used to refer to the object that a pointer variable points to. You dereference a pointer as follows: variable^ Note: Be sure to assign a value to a pointer before dereferencing it. If an uninitialized pointer is dereferenced, it might refer to any location in memory which will probably result in a runtime error. Source:
|