3 ms·
>A pointer is a particular kind of reference (a value type that enables indirection), and C++ references are another (not very different) kind. A reference in C
by cube13 15y ago
>A pointer is a particular kind of reference (a value type that enables indirection), and C++ references are another (not very different) kind. A reference in C++ amounts to an immutable pointer.
A pointer is a memory address. That's all it is. It can contain any valid memory address for the system.
A C++ reference is essentially a hard link to another declared object. As far as the compiler is concerned, a reference to an object is the object, and therefore has all the attributes that the original object has.
Pointers are like a house street addresses. They do not directly allow the user to see anything about the house, but they tell the user where the house is.
References are like what people call a certain house. I may call the house I live in "home", but my friend Bob may call it "cube13's house". Both myself and Bob use different terms for it, but we both mean the exact same physical location.