C ++中的引用和普通变量句柄之间有什么区别? [英] What is the difference between references and normal variable handles in C++?
本文介绍了C ++中的引用和普通变量句柄之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果是C ++,如果我写:
If C++, if I write:
int i = 0;
int& r = i;
那么 i
和 r
完全相等吗?
推荐答案
这意味着r是i的别称.它们都将引用相同的变量.这意味着如果您编写代码(在代码之后):
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;
然后 i
将为5.
这篇关于C ++中的引用和普通变量句柄之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文