引用变量和 const 指针变量有什么区别?
可能的重复:
C++中指针变量和引用变量的区别 < /p>
是这个问题的延续
是引用变量只是const指针变量的另一个名称?如果它们不同,声明为引用变量的变量和声明为 const 指针变量的变量之间有什么区别?
Possible Duplicate:
Difference between pointer variable and reference variable in C++
This is a continuation of this question
Is a reference variable just another name of const pointer variable? If they are different what is the difference between a variable declared as a reference variable and a variable declared as a const pointer variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只是为了好玩:) 引用不能为 NULL,但 const 指针可以。
Just for fun:) A reference can not be NULL but a const pointer can be.
好的。问题是没有像引用变量这样的东西。引用根本不是变量。它不是一个物体。它实际上根本没有尺寸。它只是原始对象的替代名称。
检查一下:
OK. The problem is that there is no such thing like reference variable. Reference is not a variable at all. It is not an object. It actually has no size at all. It is just alternative name of the original object.
Check this:
不。
它们是完全不同的东西,这里没有足够的空间来解释您需要了解的所有内容。阅读本文。实际上,请阅读整个常见问题解答。你会学到很多东西。
No.
They are completely different things, and there is not enough room to explain everything you need to know here. Read this. Actually, read the entire FAQ. You'll learn a lot.