Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.


A.2 Pointers and Memory Allocation

Another common error is to declare a pointer (usually a pointer to an object) and then use it without the memory for the target data being allocated.

/* You don't want to do this */
  DEF p:PTR TO object
  p.element:=99

There are two ways of correcting this: either dynamically allocate the memory using NEW or, more simply, let an appropriate declaration allocate it. See 14 Memory Allocation.

  DEF p:PTR TO object
  NEW p
  p.element:=99

  DEF p:object
  p.element:=99


Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.