Quote:
Originally posted by joe_bruin
argh!
let's try to clear this up.
first, a reference IS a pointer. say it with me. a reference is a pointer. the only difference is the way the language presents them to the user.
a pointer is an unsigned integer of some sort (depends on your machine / compiler / language / pointer type). it's a memory address.
|
Yes, I already got that part. Which may be one of the reasons I said 'the pointer, which is a reference' in my previous post...
Quote:
|
in c, there are no references. to a function, you can pass pointers or you can pass copies. if you type (&c), that means "the address of c"
|
That contradicts the whole pointer is a reference thing (there are no references. You can pass pointers. ...). In any case, I know that already too and said as much... unless I worded it badly...
A pointer is the memory address of x object. Passing a pointer is passing a copy of the value of the pointer, which really seems to be the same as passing the address of the object anyway - since the value of the pointer _is_ the address of the object. Passing anything which isn't a pointer will copy the whole thing.
I knew all this already
I'm unsure as to whether you understood my question.
Quote:
|
in c++, the reference syntax was added. this is an 'implicit pointer'. when you declare a function that takes a reference, that means that it implicitly grabs the address (a pointer) of the parameter passed to it, instead of making a copy. this is pretty much a convenience feature for the programmer.
|
See, this is what I was asking. How exactly does it just 'grab' the address without copying it ? Because it's seeming more and more as if there is no actual 'pass by reference', just passing by values but calling it different names...
We cleared up Java already, as far as I know...