What is the difference between references and normal variable handles in C++?

后端 未结 8 932
一生所求
一生所求 2021-01-22 23:33

If C++, if I write:

int i = 0;
int& r = i;

then are i and r exactly equivalent?

8条回答
  •  既然无缘
    2021-01-22 23:53

    That means that r is another name for i. They will both refer to the same variable. This means that if you write (after your code):

    r = 5;
    

    then i will be 5.

提交回复
热议问题