jeffc wrote:
>
> I have got a pointer question. I was told that a pointer is a variable
> holding a memory address.
You were told wrong. A pointer is a variable of type pointer that holds an
address.
He was not told wrong* - a pointer *is* a variable holding a memory address.
(At least it's supposed to - it could well be argued that 0 is not a memory
address.) He simply wasn't given enough information.
There are at least four fundamentally different flavors of pointers in
C++: regular pointers to data, pointers to regular functions, pointers
to member functions, pointers to data members. In general case some of
these kinds of pointers will hold a lot more than just a "memory
address". For this reason, in general case it is not correct to say that
a pointer "is a variable holding a memory address".
A pointer holds an address, all right (keeping in mind that in C++
terminology term "address" is a synonym for term "pointer"). Once you
start qualifying that term "address" with such undefined modifiers as
"memory" (as in your "memory address"), you start walking on thin ice.
Needlessly, I might add.
--
Best regards,
Andrey Tarasevich