Recitation - Feb 21, 2011
Pointers
- Used to hold the address of a given object.
- T* declares a pointer to an object of type T.
- Used in Pass By Address for passing data into functions through the function's parameters.
- dereferencing - used to refer to the object pointed to by the pointer.
- * operator is used to dereference a pointer.
- & - "address of" operator is used to get the address of a variable.
- const pointers
- may want to read right-to-left
- null pointer
- pointer containing the value zero
- NO object is allocated at address 0.
- Used to indicate that the pointer does not refer to an object.
- sometimes the variable NULL is used:
- array declaration - name of array acts as a pointer to the first element of the array.
int MyArray[10];
Blackjack game example
Additional Notes