Pointers

Imo
  • The concept is nice and intuitive.

  • The syntax is abysmal, terrible.

Explanations

Syntax

  • Declaration:

    int y = 2;
    int *pX = &y;
    
    or 
    
    int y = 2;
    int* pX = &y;
    
    • This implies a pointer is being declared.

    • "The 'Int Pointer' pX is equal to the address of y."

    • "pX is a pointer that points to the address of y, where y is of type int. This implies that the 'dereference' of pX is y."

  • Expression:

    a = my_function(*pX);
    
    • This implies using the dereference of pX as a parameter for the function; i.e., the value the pointer points to.

Operators ( . , -> , *  )

  • Operators are 'ways to access properties', e.g., house.window = 2 , var vector = Vector2.UP .

  • Normally, just use .  to access a property, but with pointers, ->  may be necessary.