News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

pointers and references

Started by pavellus, August 22, 2006, 01:20:30 PM

Previous topic - Next topic

pavellus

What is different between pointers and references?
Pointer are addresses to values but i can't see what for use references?

Tedd

There isn't any difference in asm :bdg
It's higher-level langauge (C++, etc) decoration really - a pointer is an address, a reference is a pointer that gets 'dereferenced' automatically (when you use it, you the get the thing it points to, not the pointer itself.)
No snowflake in an avalanche feels responsible.

pavellus

Maybe reference is a pointer to pointer or i am wrong?

Tedd

No, it's just a pointer.
But for higher-level languages (NOT asm) it's a 'magic' pointer where you get the thing it points to, not the actual pointer itself.
No snowflake in an avalanche feels responsible.

Boucly

pavellus

Did you Google it?
This is what I found - About - C++ Tutorial - Lesson 13: References

I don't think it is going to help you much though. It is basically what Tedd had already told you.

Here's a quote from the page, if it makes sense to you (it doesn't mean anything me, I don't really know what it's saying! Too technical.)

QuoteA reference is not a unique object. It is merely an alias or synonym for another object. The reference identifier (name) may be used anywhere the referred identifier may be used. Any changes to the reference also apply to the original object. Changes to the original object are also seen through the reference.

Boucly

Tedd

Okay, maybe an example will make it clearer.

a = 5
b = pointer_to_a
c = reference_to_a

d = b    // gives the address of a - it's a pointer
d = c    // gives 5 (the value of 'a') - it's a magic pointer

No snowflake in an avalanche feels responsible.

Boucly

So that's why you said it is not an assembly thing!  :U
Thanks! Funny though, I learned C++ for quite a long time but never came across references.

Boucly

zooba

Quote from: Boucly on August 22, 2006, 06:25:36 PM
I learned C++ for quite a long time but never came across references.

I'm pretty sure references only came in the most recent revision (1999, IIRC).