i think the term reference is misleading, pointers holds a memory
address, but they are variables, have their own space in memory.
var i int
var p1, p2 = &i, &i
fmt.Printf("%p, %p, %p", &i, &p1, &p2) // 0x10000000, 0x10000004, 0x10000008
while in c++ references variables for example, address are shared for
referenced and reference.
int i;
int &p1=i, &p2=i;
printf("%p, %p, %p", &i, &p1, &p2); // 0x10000000, 0x10000000, 0x10000000
probably "memory address to a value" fits better for pointers.
On Wed, Jan 9, 2019 at 12:44 PM Ian Lance Taylor <[email protected]> wrote:
>
> On Tue, Jan 8, 2019 at 9:46 PM 伊藤和也 <[email protected]> wrote:
> >
> > Can I say that a pointer is a reference or memory address to a value?
>
> Sure.
>
> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.