Tuesday, August 01, 2006

Reference and pointer

[1] References cannot be null, whereas pointers can; every reference refers to some object, although it may or may not be valid.
[2] Once a reference is created, it cannot be later made to reference another object; we say it cannot be reseated. This is often
done with pointers.

int const &r = 5; /* OK */
int const *const p = &5; /* ERROR: Can't take address of an R-value */

No comments:

Post a Comment