Reference variable memory address

Possible duplicate:
Is there a way to find the link address?

When we print the address of the actual variable and the reference variable, it shows the same address, why?

+3
source share
4 answers

A link is an alias for another variable — it's just a different name for the object that is assigned to the link.

Behind the scenes, the compiler can implement it using pointer mechanics, but if you know enough about the alias and lifetime of the link, the compiler can do without it

+10
source

. , . , () , ( ).

, . .

+6

, :

$8.3.2/3 - " , (3.7).".

+5

Because it is a link. This means that it refers to a valid variable.

int i = ...;
int& ri = i;

This example riis similar to an alias for i.

+3
source

Source: https://habr.com/ru/post/1759908/


All Articles