1. Pointer Intro #

Created Saturday 21 December 2019

(Optional - I knew this) Pointers exhaustive from scratch: https://www.youtube.com/watch?v=h-HBipu_1P0&list=PL2_aWCzGMAwLZp6LMUKI3cc7pgGsasm2_

Pointers #

Pointers are variables which hold memory addresses.

Points to - jargon #

Declaration: #

NOTE: Always initialize pointer to nullptr or NULL or 0. nullptr is recommended.

Assignment #

Dereferening(access value) #

Jargon for problematic pointers #

Source: https://www.youtube.com/watch?v=uvw5bZZT3pM

  1. Wild pointer - an uninitialized pointer.
  2. Dangling pointer - a pointer pointing to a inexistent variable(a variable that has been deallocated aka destroyed aka has gone out of scope). Access can lead to segmentation faults/crashes. Be careful with static pointers - they are initialized only once.
  3. void pointer - a pointer which is not associated with any data type. The type field(in the symbol table) is undefined. So it cannot be dereferenced(coz we don’t know how much to jump). Use - general purpose pointer, can store address of all types of variables.
  4. NULL pointer, has an address value of zero. This is not an actual address, so it is used as a sentinel. NULL may be a char or int or long depending on the compiler. In modern usage, nullptr is recommended.