哈哈哈哈哈操欧洲电影,久草网在线,亚洲久久熟女熟妇视频,麻豆精品色,久久福利在线视频,日韩中文字幕的,淫乱毛视频一区,亚洲成人一二三,中文人妻日韩精品电影

您好,歡迎來電子發(fā)燒友網(wǎng)! ,新用戶?[免費(fèi)注冊(cè)]

您的位置:電子發(fā)燒友網(wǎng)>源碼下載>C/C++語言編程>

c引用和指針的區(qū)別

大?。?/span>0.5 MB 人氣: 2017-09-27 需要積分:1

  指針和引用的定義

  在深入介紹之前我們首先來看一下指針和引用的定義、指針和引用的區(qū)別,然后分別針對(duì)指針和引用展開討論,深入細(xì)節(jié)為何有這些差異。

  指針的權(quán)威定義:

  In a declaration T D where D has the form * cv-qualifier-seqopt D1 And the type of the identifier in the declaration T D1 is “derived-declarator-type-list T”, then the type of the identifier of D is “derived-declarator-type-list cv-qualifier-seq pointer to T”。 The cv-qualifiers apply to the pointer and not to the object pointer to.

  ——摘自《ANSI C++ Standard》

  注:可能有些讀者并不明白cv-qualifier-seq

  CV-qualifiers(CV限定符)

  CV-qualifiers有三種:const-qualifier(const限定符)、Volatile-qualifier(volatile限定符)、以及const-volatile-qualifier(const-volatile限定符)。

  const類對(duì)象的非靜態(tài)、非mutable、以及非引用數(shù)據(jù)成員是const-qualified;

  volatile類對(duì)象的非靜態(tài)、非引用數(shù)據(jù)成員是volatile-qualified;

  const-volatile類對(duì)象的非靜態(tài)、非引用數(shù)據(jù)成員是const-volatile-qualified。

  當(dāng)CV-qualifiers用于限定數(shù)組類型時(shí),實(shí)際上是數(shù)組成員被該CV-qualifiers限定,而非該數(shù)組類型。

  復(fù)合類型并不因其成員被CV-qualifier限定而被該CV-qualifier限定,也就是說,即使復(fù)合類型的成員有CV-qualifier限定,該復(fù)合類型也不是CV-qualified對(duì)象。

  引用的權(quán)威定義:

  In a declaration T D where D has the form& D1 And the type of the identifier in the declaration T D1 is “derived-declarator-type-list T”, then the type of the identifier of D is “derived-declarator-type-list cv-qualifier-seq reference to T”。 Cv-qualified references are ill-formed except when the cv-qualifiers are introduced through the use of a typedef or a template type argument, in which case the cv-qualifiers are ignored.

  ——摘自《ANSI C++ Standard》

  上面這些定義初看有些難懂,如果是這樣的話,那說明你對(duì)C++還不夠熟悉,你還有很長的路要走。下面用通俗易懂的話來概述一下:

  指針-對(duì)于一個(gè)類型T,T*就是指向T的指針類型,也即一個(gè)T*類型的變量能夠保存一個(gè)T對(duì)象的地址,而類型T是可以加一些限定詞的,如const、volatile等等。見下圖,所示指針的含義:

  c引用和指針的區(qū)別

  引用-引用是一個(gè)對(duì)象的別名,主要用于函數(shù)參數(shù)和返回值類型,符號(hào)X&表示X類型的引用。見下圖,所示引用的含義:

  c引用和指針的區(qū)別

非常好我支持^.^

(0) 0%

不好我反對(duì)

(0) 0%

      發(fā)表評(píng)論

      用戶評(píng)論
      評(píng)價(jià):好評(píng)中評(píng)差評(píng)

      發(fā)表評(píng)論,獲取積分! 請(qǐng)遵守相關(guān)規(guī)定!

      ?
      南川市| 淳安县| 南澳县| 安丘市| 桐柏县| 鄄城县| 烟台市| 天台县| 浦江县| 乌拉特后旗| 南雄市| 兰考县| 巴彦淖尔市| 拜泉县| 台湾省| 平果县| 南阳市| 金华市| 肃南| 盈江县| 天门市| 徐州市| 邮箱| 昌都县| 开封市| 武邑县| 澄城县| 莒南县| 航空| 钟祥市| 安平县| 绵阳市| 牙克石市| 稷山县| 瑞金市| 昌黎县| 醴陵市| 阿图什市| 光山县| 密山市| 邻水|