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

            我參與的團隊

            搜索

            •  

            積分與排名

            • 積分 - 388624
            • 排名 - 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)  編輯 收藏 引用
            亚洲欧洲精品成人久久曰影片 | 伊人久久大香线焦AV综合影院| 国产精品中文久久久久久久| 亚洲精品午夜国产VA久久成人| 97精品久久天干天天天按摩| 久久久久久久综合日本| 亚洲午夜久久久久妓女影院| 国产99久久久国产精免费| 久久国产色av免费看| 久久WWW免费人成—看片| 久久精品黄AA片一区二区三区| 久久人人爽人爽人人爽av| 国产精品久久99| 久久久久亚洲精品无码蜜桃| 欧美久久亚洲精品| 日本久久久精品中文字幕| 成人久久免费网站| 色天使久久综合网天天| 热久久这里只有精品| A狠狠久久蜜臀婷色中文网| 色狠狠久久综合网| 亚洲国产日韩欧美久久| 久久久免费观成人影院| 99久久夜色精品国产网站| 热re99久久精品国产99热| 久久免费小视频| 91久久精一区二区三区大全| 天天爽天天狠久久久综合麻豆| 午夜精品久久久久久影视777| 久久93精品国产91久久综合| 久久国产乱子伦精品免费强| 97久久国产亚洲精品超碰热| 久久久亚洲欧洲日产国码二区 | 久久久久亚洲av无码专区喷水| 中文无码久久精品| 国产69精品久久久久9999APGF| 国色天香久久久久久久小说| 久久久久亚洲AV无码网站| 国产成年无码久久久久毛片| 亚洲国产精品久久66| 国产精品青草久久久久福利99 |