本文介紹了對指針的引用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
char *str = "Hello";
char *ptr = str;
char *&rptr = str;
ptr 和 rptr 有什么區別?我知道 rptr 是對指針的引用(理論上),但它在使用 ptr 的實現方面有何不同?
What is the difference between ptr and rptr? I understand rptr is a reference to a pointer(in theory) but how does it differ in terms of implementation with ptr?
C++ 中的引用是使用指針實現的嗎?
Are references in C++ implemented using pointers?
推薦答案
ptr 和 rptr 有什么區別?
What is the difference between ptr and rptr?
如果你這樣做 char *world = "World";rptr = world;
然后打印str
,它會打印World".如果你做 ptr = world;
然后打印 str
,它會打印Hello".
If you do char *world = "World"; rptr = world;
and then print str
, it will print "World". If you do ptr = world;
and then print str
, it will print "Hello".
這篇關于對指針的引用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!