Question about reference syntax

I see syntax as

Object p;
...
Object& o = p;

Is this something similar as

Object p;
...
Object* o = &p;

Thanks
A pointer and reference are similar in many ways and a reference is almost always implemented as a pointer but it is better to differentiate them conceptually as :
Pointers --> Variables that store address of another variable.
References --> Another name or alias of some variable stored in memory.

... Is this something similar as ...

In a way yes but conceptually they are different.
With the pointer , we are constructing o wiht the address of p while with the reference we are declaring o as an alias of p.

Also , Please Use Code Tags !
Last edited on
Topic archived. No new replies allowed.