Lecture Notes for Computer Algorithms I

16 October 2003 - Pointers


  1. The array model of memory

    1. Memory is an array of units (words, bytes).

    2. Variables get mapped into a contiguous sequence of memory units.

  2. Pointers

    1. The memory-unit indices are also know as pointers.

    2. The distinguished null pointer.

  3. Pointer Variables

    1. You can declare variables that hold pointer values.

      1. This recursion can go on for ever, but probably shouldn't.

    2. Pointer variables are, for the most part, just like all other variables.

  4. Pointer operations

    1. Find the address of variables

    2. Follow addresses to get values

    3. Compare pointers to one another

    4. Pointer arithmetic

      1. Scaled arithmetic

    5. Pointer difference

    6. Pointer operation idioms

      1. array access [].

      2. member field access ->.

  5. Pointers as procedure parameters.

    1. Call-by-value semantics.

    2. Passing values back out of the function.


This page last modified on 17 October 2003.