arrays
- when declared
int x[10]
, you cannot overwritex
with another value- array variables are considered constants
int array[3][2]
is an array of size three with integer arrays size two
[
[int, int],
[int, int],
[int, int],
]
- when passed as a parameter, will be
function(int **y)
subscript operator
- can work on a pointer expressions
x[i] == *(x + i)
- is a binary operator (requires two operands)
operand1[operand2]
- the address is computed by the subscript operator and takes into account the size of the elements in the array
- therefore the index is independent of the actual address of the element
- pointer and array math are interchangeable, since arrays are essentially pointers
sizeof operator
- entirely compile-time
- replaces all the calls with the given number
sizeof(array)
- the number of elements can be determined by
sizeof(array)/sizeof(array[i])
- since a pointer is a memory address, when doing
pointer[1]
orpointer + 1
you are actually doingmemoryLocation + (1 * sizeof(dataType))
- strictly based on the type
- even if the type is a pointer to another type, still is pointer type
- any expression passed in will not be evaluated
memory
word
is the size of a single place of storage / memory in a computer- typically 32bit or 64bit
- structs and classes are larger than the primitive data types