Difference between Reference and Pointer(引用和指针有什么区别)

指针就是对象在内存中的地址
而引用是对象的别名,其本质上是一个功能受限但是安全性更高的指针.
两者的区别在于:引用访问变量的话是直接访问,而指针是间接访问。
第二点 引用就像是一个变量的别名,本身不会单独分配自己的内存空间。但是指针的话需要额外的内存空间去储存。

pointer is the address of the object in memory
but the reference is another name of the object, it is a pointer with limited functionality but higher security.

posted @ 2020-11-01 00:12  EvanMeetTheWorld  阅读(23)  评论(0)    收藏  举报