Why are pointers to a reference illegal in C++?

Because a reference is not a thing that can be pointed at, which in turn is because it does not actually have to be represented anywhere in memory. References exist to give alternate names to already-existing things. You can get a pointer to the renamed thing, but that is a pointer to a value, not a pointer to a reference.


The high-level concept that references implement is just another name for an existing object. You can have a pointer to an object (or function), but you can't have a pointer to an object's name. For this very reason, the idea of a pointer to a reference makes no sense. In other words, references are immaterial, in general case they simply do not exist in memory. They don't exist as something that can be pointed to.

It is true that in many cases in practice references do occupy memory (and are implemented as pointers in disguise). But that just an implementation detail specific to some particular contexts. In general case references do not occupy memory, as is explicitly stated in the language specification which immediately follows from the language specification.


A pointer needs to point to an object. A reference is not an object.

If you have a reference r, once it is initialized, any time you use r you are actually using the object to which the reference refers.

Because of this, you can't take the address of a reference to be able to get a pointer to it in the first place. Consider the following code:

int x;
int& rx = x;

int* px = ℞

In the last line, &rx takes the address of the object referred to by rx, so it's exactly the same as if you had said &x.


What would be the difference between a pointer to a reference (to the object) and a pointer to the actual object? The reference cannot be changed to refer to another object. Just use a regular pointer to the object in question.

On the other hand, a reference to a pointer, like any other reference, gives you a modifiable handle to a particular variable. It happens to be a pointer in this case.