亚洲色一色噜一噜噜噜_在线国产精品一区二区_91国自产拍 精品_国产伦三级一区二区

  • <object id="nlumt"><tt id="nlumt"><pre id="nlumt"></pre></tt></object>
    <legend id="nlumt"><mark id="nlumt"></mark></legend>
    <pre id="nlumt"><tt id="nlumt"><rt id="nlumt"></rt></tt></pre>

    <bdo id="nlumt"><delect id="nlumt"></delect></bdo>

      汶上信息港

      標(biāo)題: 構(gòu)造函數(shù)與析構(gòu)函數(shù)調(diào)用順序 [打印本頁]

      作者: hbhdgpyz    時間: 2008-9-29 20:23
      標(biāo)題: 構(gòu)造函數(shù)與析構(gòu)函數(shù)調(diào)用順序
      <P>派生類與基類中<FONT color=#0000ff>構(gòu)造函數(shù)的調(diào)用順序</FONT>是<FONT color=#ff0000>先調(diào)用基類</FONT>的構(gòu)造函數(shù)對基類成員進(jìn)行初始化。然<FONT color=#ff0000>后執(zhí)行派生類</FONT>的構(gòu)造函數(shù),如果基類仍是派生類,則這個過程遞歸進(jìn)行。</P>
      ' c) E' r" a1 u. {  H- V, m7 F6 B- N/ D<P>當(dāng)派生類還<FONT color=#ff0000>包括對象成員</FONT>時,則<FONT color=#0000ff>基類</FONT>的<FONT color=#ff0000>構(gòu)造函數(shù)先被調(diào)用</FONT>,<FONT color=#0000ff>對象成員</FONT>的構(gòu)造函數(shù)<FONT color=#0000ff>次之</FONT>,<FONT color=#ff0000>最后執(zhí)行派生類</FONT>的<FONT color=#0000ff>構(gòu)造函數(shù)</FONT>。在有<FONT color=#ff0000>多個</FONT><FONT color=#0000ff>對象成員</FONT>的情況下,這些對象成員的<FONT color=#ff0000>調(diào)用順序取決于</FONT>它們在派生類中<FONT color=#ff0000>被說明</FONT>的順序。</P>+ W/ J0 C$ I, H( ]! m8 L
      <P>派生類與基類中<FONT color=#0000ff>析構(gòu)函數(shù)</FONT>的調(diào)用順序與上面的執(zhí)行構(gòu)造函數(shù)的順序正好相反。即<FONT color=#ff0000>先執(zhí)行派生類</FONT>的析構(gòu)函數(shù),<FONT color=#ff0000>再調(diào)用基類</FONT>的析構(gòu)函數(shù)。</P>
      5 d" j) c( F. D% U<P>多重繼承的構(gòu)造函數(shù)與析構(gòu)函數(shù)調(diào)用順序沒有作要求,但是我們還是了解一下,這種情況下,基類構(gòu)造函數(shù)執(zhí)行順序按它們被繼承時說明的順序依次調(diào)用,與它們在被始化列表中的順序無關(guān)。</P>




      歡迎光臨 汶上信息港 (http://loveproblemguru.com/) Powered by Discuz! X3.5