久久久久久久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++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: 日本小电影网站 | 欧美一级大片 | 国产免费一区二区三区 | 麻豆国产一区二区三区四区 | 国产亚洲精品精品国产亚洲综合 | 成人av网站在线观看 | 精品久久影院 | 在线日韩av电影 | 午夜视频一区二区 | 美女天天干 | 免费成人在线网站 | 久久精品视频在线观看 | 人人澡人人爱 | 91成人午夜性a一级毛片 | 国产精品久久9 | 视频二区 | 成人三级视频在线观看 | 日日摸夜夜添夜夜添特色大片 | 在线观看av网站永久 | 日韩精品一区二区三区 | 亚洲最新网址 | 亚洲国产精品久久久久久 | 能看的av网站 | 国产网站在线免费观看 | 欧美精品片 | 国产精品免费一区二区三区 | 99久久婷婷国产精品综合 | 黑人久久| 日日噜噜噜夜夜爽爽狠狠视频97 | 午夜电影在线播放 | 中文久久 | 成人免费视频观看 | 国产精品综合一区二区 | av网站免费| 婷婷二区 | 日韩视频a | 自拍第一页 | 98成人网| 久久久久亚洲国产| 久久精品一区二区三区四区 | 日韩中文字幕网 |