引用和指针的区别 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.
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.
相关文章推荐
- 空悬指针和野指针的区别(the difference between dangling pointer and wild pointer)
- 详解c++ 引用(reference)与 指针(pointer)的区别与联系
- difference between pointer and reference
- The differences between pointer and reference in C++
- more effective c++:the difference between pointer and reference
- C++中指针(pointer)和引用(reference)的区别和联系
- What are the differences between a pointer variable and a reference variable in C++?
- Difference between pointer variable and reference variable in C++
- pointer(指针)和 reference(引用)之间的区别
- 详解c++ 引用(reference)与 指针(pointer)的区别与联系
- What are the differences between a pointer variable and a reference variable in C++?
- 指针(Pointer)和引用(Reference)的区别
- Difference between final. finally , and finalize() final, finally 和finalize区别
- 对象引用与托管指针(object references and managed pointers)
- 文科和理科的区别(What is the difference between science and engineering)?
- What is the difference between const and static readonly?(const 和 static readonly 的区别?)
- c++中的对象引用(object reference)与对象指针的区别
- what the difference between __weak and __block reference?
- c++ 指针point 和引用reference的区别
- “标准容器中存放引用”与“指向引用的指针(pointer to reference)”