| | | | | |

The Bracket Operator

  • The bracket operator is implemented by computing the address of the ith object
  • base = A = address of A[0]
    
    address of element i
         = base + offset
         = base + i * sizeof(T)
    
    A[i] = reference to element at this address
    
  • Pointer must know its type to compute addresses using sizeof(T)
  • Note carefully the distinction between A and A[0]

| | Top of Page | 5. C/C++ Pointers, Arrays, and Pointer Arithmetic - 9 of 17