gpt4 book ai didi

c++ - 引用指针

转载 作者:IT老高 更新时间:2023-10-28 21:50:48 26 4
gpt4 key购买 nike

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com