If we have code:
int b = 10;
int* a = &b;
std::cout << a << \" \" << &a << \" \";
As the result, the addres
A pointer has the value of a variable's address
I assume by a variable you mean the object corresponding to the variable. Nonetheless, this is not strictly true, and it's the edgecases where we start to make distinctions between addresses and pointer values.
There are pointer values that don't point at objects at all. Consider null pointers, for example.
Addresses, by definition, do point at objects... or functions.
what's the meaning of address of a pointer?
The term address of a pointer makes sense if you can imagine a variable declared to store a pointer (e.g. T *var;
) and you take the address of it (&var
).
so why we have the address of an address?
An address is a type of pointer value, but pointer values don't point at values; they point at objects or functions. &a
is different to a
because the two pointers point at different objects; one points at a
and the other points at b
.