On Thu, Apr 2, 2009 at 4:52 PM, Michael Comperchio <[email protected]> wrote:
> I'm not really a C++ guru. But I do know they are not equiv. References
> cannot be null, Because they are really just another name for the same
> variable. Because of that they cannot be simply declared:
I think we're getting confused by the concept of 'passing by
reference/passsing by value' versus the C++ aliasing mechanism we call
'references'. Passing the address of a variable into a function is
called 'passing by reference' whereas passing by value is passing a
copy of the original into the function (so modfication to the pointer
modifies the original, whereas when you pass by value, you don't
modify the original). When you 'pass by reference' you are passing a
pointer (ie., taking the address of your variable), so in this sense,
the reference is the pointer.
In C++, we have the syntactical sugar of using the reference mechanism
which is a way of creating an aliasing to a variable. It makes
'passing by reference' much cleaner and prettier and achieves a
similar thing to the C style of using pointers to 'pass by reference'
but without the more confusing syntax of usign pointers.
-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
If I were to divulge it, it would overturn the world."
-- Jelaleddin Rumi