R
Ramkumar R K
what is the difference between objects and pointers?
Ramkumar said:what is the difference between objects and pointers?
Ramkumar R K said:what is the difference between objects and pointers?
what is the difference between objects and pointers?
Hallvard B Furuseth said:A pointer is an object which contains the address of another object (or
of a function).
Richard said:Or possibly of itself <g>.
pete said:The result of the & operator, is a pointer, though not an object.
Richard Heathfield said:Not necessarily. In this code fragment:
int i;
int *p = &i;
&i is a pointer, but not an object.
Mike said:A pointer *is* an object.
Richard said:A pointer is an object,
Richard said:My hovercraft, OTOH, is full of eels - which is just as relevant.
pete said:The result of the & operator, is a pointer, though not an object.
Hallvard said:Are you sure? Where does the standard say this?
The program has to put the result somewhere
- maybe in memory, maybe in a register.
In 'comp.lang.c' said:Not necessarily. In this code fragment:
int i;
int *p = &i;
&i is a pointer, but not an object.
Hallvard said:Are you sure? Where does the standard say this?
Emmanuel said:As I undersdand it, &i is a pointer constant (like NULL in a
pointer context, or the name of an array). It's not a object
because it's a constant value. Constant values have no address.
Hence, the assertion "a pointer is an object" sounds good to me.
Please, let me know if I'm wrong.
Ramkumar said:what is the difference between objects and pointers?
Don't fight it so hard. "pointer to the address of" indeed. I contendRichard said:Exceptions include the value yielded by the & "address-of" operator, and the
unadorned name of a function (which is converted to a pointer to the
address of that function, but AFAICT is not an object).
Joe said:Don't fight it so hard. "pointer to the address of" indeed.
I contend
simply that we confuse "address" and "pointer" too often. An address is
a value with pointer type but it is a value, not an object. The value
yielded by the & operator is an address. Calling it a pointer is wrong.
Expressing the name of a function yields the address of it. Not a
pointer.
Don't fight it so hard. "pointer to the address of" indeed.
I contend simply that we confuse "address" and "pointer" too often.
An address is a value with pointer type but it is a value, not an
object. The value yielded by the & operator is an address.
Calling it a pointer is wrong.
Expressing the name of a function yields the address of it. Not a
pointer.
We all know that C is value oriented. We pass arguments to functions by
value. Functions return values to their callers. But we 'say' it wrong.
Because the value returned is of pointer type we call it 'pointer'
instead of value.
I commend the reader to the first sentence of Chapter 5 of K&R 1 and 2.
"A pointer is a variable that contains the address of another variable."
What's so hard about this?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.