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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ## 委托構造 ``` #include <iostream> class Base { public: int value1; int value2; Base() { value1 = 1; } Base(int val):Base() { value2 = val; } }; int main() { Base b; std::cout << b.value1; // output: 1 } ``` ## 繼承構造 ``` #include <iostream> class Base { public: int value1; int value2; Base() { value1 = 2; } Base(int val):Base() { value2 = val; } }; class SubBase: public Base { public: using Base::Base; }; int main() { SubBase b; std::cout << b.value1; // 1 } ``` ## 顯式虛函數重載 override ``` struct Base { virtual void foo(int); }; struct SubClass: Base { virtual void foo(int) override; // 合法 virtual void foo(float) override; // 非法, 父類沒有此虛函數 }; ``` final ``` struct Base { virtual void foo() final; }; struct SubClass1 final : Base { }; // 合法 // // struct SubClass2 : SubClass1 { // }; // 非法, SubClass1 已 final // // struct SubClass3 : Base { // void foo(); // 非法, foo 已 final // }; ``` ## 強類型枚舉 在傳統 C++中,枚舉類型并非類型安全,枚舉類型會被視作整數,則會讓兩種完全不同的枚舉類型可以進行直接的比較(雖然編譯器給出了檢查,但并非所有) ``` #include <iostream> #include <vector> enum class ENUM:unsigned int { V1=1, V2=2, V3=2, }; // 也用 cout 輸出枚舉值 template<typename T> std::ostream& operator<<( typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e) { return stream << static_cast<typename std::underlying_type<T>::type>(e); } int main() { if (ENUM::V1==ENUM::V2) { std::cout << "true"; }else { std::cout << "false"; } //也可以通過 cout 輸出枚舉值 std::cout << ENUM::V3; // 2 } ```
                  <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>

                              哎呀哎呀视频在线观看