menu prev next

POINTERS: Referencing data types that do not yet exist

The most common use of pointers is to reference structured types like records. Often, the record definition will contain a reference to the pointer,

	type  rptr = ^recdata;
		recdata = record
			number : integer;
			code   : string;
			nextrecord : rptr
		end;

	var  currentrecord : rptr;

In this example, the definition for the field nextrecord of recdata includes a reference to the pointer of type iptr. As you can see, rptr is defined as a pointer of type recdata, which is defined on the next lines. This is allowed in Pascal, for pointer types.

Using a definition of recdata, this will allow us to create a list of records, as illustrated by the following picture.

list of records

In this case, a list is simply of number of records (all of the same type), linked together by the use of pointers.


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.
menu prev next

1