久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

常量之間的區別.指針和引用?

Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
本文介紹了常量之間的區別.指針和引用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

常量指針和引用有什么區別?

What is the difference between a constant pointer and a reference?

常量指針顧名思義是不能再綁定的.參考文獻也是如此.

Constant pointer as the name implies can not be bound again. Same is the case with the reference.

我想知道在哪種情況下,一種會比另一種更受歡迎.他們的 C++ 標準和實現有何不同?

I wonder in what sort of scenarios would one be preferred over the other. How different is their C++ standard and their implementations?

干杯

推薦答案

const 指針有 3 種類型:

There are 3 types of const pointers:

//Data that p points to cannot be changed from p
const char* p = szBuffer;

//p cannot point to something different.  
char* const p = szBuffer;

//Both of the above restrictions apply on p
const char* const p = szBuffer;

上面的方法#2 與參考文獻最相似.

Method #2 above is most similar to a reference.

引用和上述所有 3 種類型的 const 指針之間存在主要區別:

There are key differences between references and all of the 3 types of const pointers above:

  • 常量指針可以為 NULL.

  • Const pointers can be NULL.

引用沒有自己的地址,而指針有.
引用的地址是實際對象的地址.

A reference does not have its own address whereas a pointer does.
The address of a reference is the actual object's address.

一個指針有它自己的地址,并且它的值是它指向的值的地址.

A pointer has its own address and it holds as its value the address of the value it points to.

在此處查看 我的回答參考和指針之間的更多區別.

這篇關于常量之間的區別.指針和引用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
Is pointer comparison undefined or unspecified behavior in C++?(C++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: 91高清在线观看 | 精品亚洲一区二区 | 美国一级毛片a | 亚洲a一区二区 | 欧美日韩亚洲一区 | 日韩久久久久久久久久久 | 男女国产视频 | 日本又色又爽又黄的大片 | 天天操夜夜骑 | 亚洲国产中文字幕 | 黑人巨大精品欧美一区二区一视频 | 亚洲一级淫片 | 国产精品不卡 | 成人高清视频在线观看 | 国产精品成人一区 | 成人国产精品色哟哟 | 亚洲一级在线 | 亚洲一区二区在线播放 | 成人在线精品 | 午夜精品一区二区三区免费视频 | 播放一级黄色片 | 国产精品www | 久久精品一区 | 日韩中文一区二区三区 | 欧美日韩亚洲国产综合 | 欧美精品欧美精品系列 | 国产精品久久久久一区二区三区 | 久久国产成人 | 国产精品视频一区二区三区 | 性色av网站 | 99精品视频免费观看 | 91原创视频 | 亚洲九九色 | av手机在线播放 | 日韩久久综合 | 亚洲视频一区在线观看 | 成人毛片在线观看 | 日本高清视频在线播放 | 毛片免费观看视频 | 亚欧精品 | 婷婷国产一区二区三区 |