您的位置:首页 > Web前端

引用和指针的区别 Difference between pointer and reference

2010-05-31 10:43 459 查看
1. 引用必须初始化,而指针不用;

2. 引用一旦初始化便不可以指向其他对象,而指针可以;

3. 引用不能指向NULL,而指针可以;

4. 动态分配的内存必须由指针指向,而不能有引用指向;

5. 指针可以进行增减运算,并且适用于任何指针算术操作,而引用不行。

1. Reference should be initialized and pointer need not be.

2. Reference can’t be changed to some other objects it is once initialized but pointer can be.

3. The dynamic allocated memory can only be pointed to by a pointer.

4. Reference can’t point to NULL and pointer can.

5. Pointer can be incremented or decremented and subjected to any pointer arithmetic operations, but reference can’t.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: