<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                正常情況下我們可以通過使用相同的函數名而不同的參數或者返回值類型等因素來實現函數重載。但是在類的繼承時這樣的情況無法實現,因為類繼承時,同名函數將會被掩蓋,只要同名不管函數參數和返回值等類型是否相同都會被掩蓋掉。如下進行簡單的測試就可以很清楚的了解這一特性了。 1.正常情況下的函數重載: ~~~ #include <cstdio> #include <cstring> #include <iostream> using namespace std; void bar(int c) { cout << "In function : void bar(int c) : c = " << c << endl; } void bar() { cout << "In function : void bar()" << endl; } int main() { int c = 2; bar(c); bar(); return 0; } ~~~ 以上代碼就是一個最簡單的重載代碼。 2.在類的繼承關系中的情況 ~~~ #include <cstdio> #include <cstring> #include <iostream> using namespace std; namespace iaccepted { class A { public: void bar(int c) { cout << "In function : void bar(int c) : c = " << c << endl; } }; class B : public A { public: void bar() { cout << "In funcion : void bar()" << endl; } }; } int main() { int c = 2; iaccepted::B b; b.bar(); b.bar(c);//錯誤,b中沒有已int為參數的bar函數可供調用 return 0; } ~~~ 這就是在類的繼承關系中類似的情形。A中有一個bar(int)類型的函數,B中有一個bar()類型的函數,其實類B雖然繼承類A中的內容,但是由于B中的bar與A中的函數同名,不管參數或者返回值是否相同,B中的bar都會掩蓋掉A中的所有名為bar的函數(如果不止存在一個的話)。 結論: 類的繼承關系中派生類中的函數會掩蓋基類中的同名函數,而不管這些函數的參數和返回值類型等其他因素。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看