6.10. Handling Pointers

Do not go outside of either physical or logical array bounds [ARRAY-BOUND: 1-8 points]

Do not use an array index that is outside of the array bounds. If only a prefix or suffix of an array has relevant information in it, only look at the relevant information. For example, if you have created an array of physical size 100, but you have read information into the first 30 slots, then do not do a loop over all 100 slots just to see those 30 values.

Do not delete any pointer that was not given to you by new. If you delete an array, follow delete by [ ]. [BAD-DELETE: 2-8 points]

If you perform
  delete p;
then you must have obtained pointer p using new, for example by
  p = new T;
If you perform
  delete [] p;
then you must have obtained pointer p using new, for example by
  p = new T[n];

Do not make use of a dangling pointer [DANGLING-POINTER: 1-8 points]

A dangling pointer is a pointer that points to something that your program should not use. Do not make use of it.

Avoid memory leaks [DANGLING-POINTER: 1-2 points]

A memory-leak occurs when a program loses access to memory without deleting it.

Avoid memory faults during execution [MEMORY-FAULT: 5-50 points]

A memory fault occurs when a program uses an address that it does not own. The program stops immediately.