Differences Between pointers and references in C++

  1. A pointer can be declared uninitialized, but a reference must be declared referring to something
  2. A pointer can be reassigned, but a reference cannot be reassigned – assigning to it changes the referent
  3. Pointers can be NULL, but there is no equivalent for references – they always need to refer to a valid object
  4. You can take the address of a pointer, but you can’t take the address of a reference (you’ll get the address of the referent)
  5. You can make a pointer to a pointer, or a reference to a pointer, but you can’t make a reference to a reference
  6. You can do arithmetic with pointers, but you can’t do arithmetic with references (it would attempt to do arithmetic with the referent)
  7. You de-reference pointers, but you don’t de-reference references (they are automatically de-referenced)
  8. When you call a function that takes a pointer, you can always see at the call site that the argument is a pointer (because it’s declared as a pointer variable, or you take the address of it), but the creation of a reference by function call isn’t explicit at the call site