• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            醬壇子

            專注C++技術 在這里寫下自己的學習心得 感悟 和大家討論 共同進步(歡迎批評!!!)

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              66 Posts :: 16 Stories :: 236 Comments :: 0 Trackbacks

            公告

            王一偉 湖南商學院畢業 電子信息工程專業

            常用鏈接

            留言簿(19)

            我參與的團隊

            搜索

            •  

            積分與排名

            • 積分 - 387045
            • 排名 - 64

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            class   shape   {  
              public:  
                        shape(int){}  
              };  
               
              class   circle:   public   shape   {  
              public:  
                      circle(int):   shape(1){}  
              };  
               
              class   square:   public   shape   {  
              public:  
                      square(int):   shape(1){}  
              };  
               
              class   bizzare:   public   circle,   public   square   {  
              public:  
                      bizzare():   circle(1),   square(1){}  
              };  
              這里用的就是一般的多重繼承,沒有虛擬繼承的存在。在bizzare(之所以叫這個名字,因為……從circle和square繼承而來實在是夠怪異的了,呵呵)類的member   initialization   list中,只需要寫circle和square類的構造函數就可以了,后兩者再分別調用它們的基類shape(分別的兩個實例)的構造函數。  
               
              而如果是虛擬繼承:  
              class   shape   {  
              public:  
                        shape(int){}  
              };  
               
              class   circle:   public   virtual   shape   {  
              public:  
                      circle(int):   shape(1){}  
              };  
               
              class   square:   public   virtual   shape   {  
              public:  
                      square(int):   shape(1){}  
              };  
               
              class   bizzare:   public   circle,   public   square   {  
              public:  
                      bizzare():   circle(1),   square(1),   shape(1){}  
              };  
              則必須在most   derived的派生類中初始化虛擬基類。  
               
              TC++PL上肯定有說的,在class   hierarchy那章。




            這是語言規定。因為只有一個sharp對象,從哪個基類構造都有問題(因為它們可能調用虛基類的不同構造函數,產生二義性),所以標準規定必須在most   derived構造時顯式或隱式(虛基類有缺省構造函數時)構造虛基類。樓主的例子里sharp沒有缺省構造函數,所以必須顯式構造。  
              TC++PL里有:  
              The   constructor   of   a   virtual   base   is   invoked   (implicitly   or   explicitly)   from   the   constructor   for   the   complete   object   (the   constructor   for   the   most   derived   class).


            虛擬繼承:發生在多重繼承上,比如:一個類繼承兩類,但是這兩個類都繼承一個類。(類圖出現環),即“孫子”到“爺爺”的路徑超過一條時,使用,要不會有兩個“爺爺”  
               
              虛函數:與繼承完成多態工作。是面向對象關鍵中的關鍵。由于面向對象的設計是自頂向下的,先功能定義在實現。繼承主要有實現繼承和接口繼承,都需要多態  
            posted on 2007-09-21 06:47 @王一偉 閱讀(1369) 評論(0)  編輯 收藏 引用
            青青久久精品国产免费看| 久久精品国产网红主播| 久久久这里有精品中文字幕| 国产激情久久久久影院小草| 亚洲va久久久久| 国产99久久精品一区二区| 久久国产V一级毛多内射| 久久综合亚洲色HEZYO社区 | 色偷偷88888欧美精品久久久| 欧美精品久久久久久久自慰| 丰满少妇人妻久久久久久4| 久久综合色老色| 99久久亚洲综合精品网站| 久久久久久午夜精品| 国内精品久久久久久久亚洲| 亚洲色大成网站www久久九| 国产激情久久久久影院老熟女免费| 久久精品亚洲AV久久久无码| 久久av高潮av无码av喷吹| 久久99精品国产一区二区三区 | 久久这里只有精品久久| 麻豆精品久久久久久久99蜜桃 | 99久久人人爽亚洲精品美女| 亚洲国产精品无码久久久秋霞2 | 久久福利资源国产精品999| 亚洲午夜久久影院| 久久久久亚洲精品无码蜜桃| 亚洲一级Av无码毛片久久精品| 久久电影网2021| 久久婷婷激情综合色综合俺也去| 国产精品中文久久久久久久| 久久久国产精华液| 国产成人精品久久一区二区三区av| 97久久国产亚洲精品超碰热| 色综合久久无码中文字幕| 亚洲色欲久久久综合网东京热| 久久久一本精品99久久精品88| 18禁黄久久久AAA片| 久久综合视频网| 少妇久久久久久被弄高潮| 久久精品夜夜夜夜夜久久|