• <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)

            我參與的團隊

            搜索

            •  

            積分與排名

            • 積分 - 388627
            • 排名 - 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 @王一偉 閱讀(1380) 評論(0)  編輯 收藏 引用
            美女久久久久久| 久久久一本精品99久久精品66| 久久99精品久久久久久噜噜| 久久久久久国产a免费观看不卡| 性做久久久久久久久老女人| 久久精品国产亚洲AV蜜臀色欲| 亚洲国产精品久久久久| 久久人人爽人人人人爽AV | 精品精品国产自在久久高清| 久久无码AV中文出轨人妻| 久久精品欧美日韩精品| 久久人搡人人玩人妻精品首页| 奇米影视7777久久精品| 午夜精品久久久久9999高清| 久久99精品久久只有精品| 伊人久久大香线蕉综合网站| 久久久精品波多野结衣| 久久精品国产亚洲综合色 | 久久久久99精品成人片直播| 99久久综合国产精品免费| 94久久国产乱子伦精品免费| 久久精品国产亚洲AV麻豆网站| 国产偷久久久精品专区 | 伊人久久大香线蕉亚洲五月天| 久久噜噜久久久精品66| 久久亚洲国产欧洲精品一| 热re99久久精品国99热| 久久久久久久久久久久中文字幕| 久久人人爽人人人人爽AV| 亚洲欧洲精品成人久久曰影片 | 久久99这里只有精品国产| 狠狠色综合网站久久久久久久| 伊人久久综合热线大杳蕉下载| 狠狠狠色丁香婷婷综合久久五月| 久久人人爽爽爽人久久久| 国内精品久久久久影院一蜜桃| 韩国三级大全久久网站| 精品久久久久久99人妻| 亚洲国产精品一区二区三区久久 | 久久―日本道色综合久久| 四虎国产精品免费久久久|