char *str = "Hello";
char *ptr = str;
char *&rptr = str;
ptr 和 rptr 有什么区别?我知道 rptr 是对指针的引用(理论上),但它在 ptr 的实现方面有何不同?
C++ 中的引用是否使用指针实现?
最佳答案
What is the difference between ptr and rptr?
如果你这样做 char *world = "World"; rptr = world;
然后打印str
,就会打印出“World”。如果您执行 ptr = world;
然后打印 str
,它将打印“Hello”。
关于c++ - 引用指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3128662/