久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='BMbeV'></bdo><ul id='BMbeV'></ul>
    <i id='BMbeV'><tr id='BMbeV'><dt id='BMbeV'><q id='BMbeV'><span id='BMbeV'><b id='BMbeV'><form id='BMbeV'><ins id='BMbeV'></ins><ul id='BMbeV'></ul><sub id='BMbeV'></sub></form><legend id='BMbeV'></legend><bdo id='BMbeV'><pre id='BMbeV'><center id='BMbeV'></center></pre></bdo></b><th id='BMbeV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BMbeV'><tfoot id='BMbeV'></tfoot><dl id='BMbeV'><fieldset id='BMbeV'></fieldset></dl></div>
    1. <small id='BMbeV'></small><noframes id='BMbeV'>

    2. <legend id='BMbeV'><style id='BMbeV'><dir id='BMbeV'><q id='BMbeV'></q></dir></style></legend>
      <tfoot id='BMbeV'></tfoot>

      從構(gòu)造函數(shù)的初始化列表中捕獲異常

      Catching exceptions from a constructor#39;s initializer list(從構(gòu)造函數(shù)的初始化列表中捕獲異常)

        <tfoot id='STTqB'></tfoot>
        <i id='STTqB'><tr id='STTqB'><dt id='STTqB'><q id='STTqB'><span id='STTqB'><b id='STTqB'><form id='STTqB'><ins id='STTqB'></ins><ul id='STTqB'></ul><sub id='STTqB'></sub></form><legend id='STTqB'></legend><bdo id='STTqB'><pre id='STTqB'><center id='STTqB'></center></pre></bdo></b><th id='STTqB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='STTqB'><tfoot id='STTqB'></tfoot><dl id='STTqB'><fieldset id='STTqB'></fieldset></dl></div>
        • <legend id='STTqB'><style id='STTqB'><dir id='STTqB'><q id='STTqB'></q></dir></style></legend>
            <bdo id='STTqB'></bdo><ul id='STTqB'></ul>
                <tbody id='STTqB'></tbody>

              <small id='STTqB'></small><noframes id='STTqB'>

              1. 本文介紹了從構(gòu)造函數(shù)的初始化列表中捕獲異常的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                這是一個奇怪的問題.我有一個 A 類.它有一個 B 類項目,我想在 A 的構(gòu)造函數(shù)中使用初始化列表對其進(jìn)行初始化,如下所示:

                Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so:

                class A {
                    public:
                    A(const B& b): mB(b) { };
                
                    private:
                    B mB;
                };
                

                有沒有辦法在仍然使用初始化列表方法的同時捕獲可能由 mB 的復(fù)制構(gòu)造函數(shù)拋出的異常?或者我是否必須在構(gòu)造函數(shù)的大括號內(nèi)初始化 mB 才能進(jìn)行 try/catch?

                Is there a way to catch exceptions that might be thrown by mB's copy-constructor while still using the initializer list method? Or would I have to initialize mB within the constructor's braces in order to have a try/catch?

                推薦答案

                閱讀http://weseetips.wordpress.com/tag/exception-from-constructor-initializer-list/)

                經(jīng)過更多挖掘,這些被稱為功能嘗試塊".

                After more digging, these are called "Function try blocks".

                我承認(rèn)在我去看之前我也不知道這一點(diǎn).你每天都會學(xué)到一些東西!我不知道這是否是對我這些天很少使用 C++、我缺乏 C++ 知識,或者語言中經(jīng)常出現(xiàn)的拜占庭特性的控訴.嗯 - 我仍然喜歡它:)

                I confess I didn't know this either until I went looking. You learn something every day! I don't know if this is an indictment of how little I get to use C++ these days, my lack of C++ knowledge, or the often Byzantine features that litter the language. Ah well - I still like it :)

                為了確保人們不必跳轉(zhuǎn)到另一個站點(diǎn),構(gòu)造函數(shù)的 try 塊的語法結(jié)果是:

                To ensure people don't have to jump to another site, the syntax of a function try block for constructors turns out to be:

                C::C()
                try : init1(), ..., initn()
                {
                  // Constructor
                }
                catch(...)
                {
                  // Handle exception
                }
                

                這篇關(guān)于從構(gòu)造函數(shù)的初始化列表中捕獲異常的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                When and how should I use exception handling?(我應(yīng)該何時以及如何使用異常處理?)
                Scope of exception object in C++(C++中異常對象的范圍)
                Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別)
                Should the exception thrown by boost::asio::io_service::run() be caught?(應(yīng)該捕獲 boost::asio::io_service::run() 拋出的異常嗎?)

                  <tbody id='CKhLA'></tbody>
                <i id='CKhLA'><tr id='CKhLA'><dt id='CKhLA'><q id='CKhLA'><span id='CKhLA'><b id='CKhLA'><form id='CKhLA'><ins id='CKhLA'></ins><ul id='CKhLA'></ul><sub id='CKhLA'></sub></form><legend id='CKhLA'></legend><bdo id='CKhLA'><pre id='CKhLA'><center id='CKhLA'></center></pre></bdo></b><th id='CKhLA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='CKhLA'><tfoot id='CKhLA'></tfoot><dl id='CKhLA'><fieldset id='CKhLA'></fieldset></dl></div>
              2. <legend id='CKhLA'><style id='CKhLA'><dir id='CKhLA'><q id='CKhLA'></q></dir></style></legend>
                • <tfoot id='CKhLA'></tfoot>

                    <small id='CKhLA'></small><noframes id='CKhLA'>

                          <bdo id='CKhLA'></bdo><ul id='CKhLA'></ul>
                          主站蜘蛛池模板: 免费精品视频一区 | 久久99精品久久久久久噜噜 | 在线小视频 | 久久毛片| 久久九九99 | 国产小视频在线观看 | 欧美性猛交一区二区三区精品 | 中文字幕乱码亚洲精品一区 | 欧美综合一区二区三区 | 日韩a在线| 欧美精品网 | 亚洲视频中文 | jlzzjlzz国产精品久久 | 精品国产一区久久 | 国产精品福利久久久 | 91 在线 | 天天干天天草 | 日本成人午夜影院 | 爱爱爱av| 九九热免费在线观看 | 青青草这里只有精品 | 成人深夜福利在线观看 | 一区二区三区国产 | 欧美一区二区三区在线播放 | 国产精品无码久久久久 | 亚洲国产精品一区二区久久 | 一级黄色录像片子 | 国产精品99久久久久久大便 | 中文字幕亚洲精品 | 视频一区在线播放 | 欧洲精品一区 | 国产一区二区三区久久久久久久久 | 99热在线免费 | 9999视频 | 日本一级淫片免费啪啪3 | 国产一区二区三区在线 | 91看片在线 | 久久精品亚洲国产 | 午夜影院| 亚洲精品女人久久久 | 国产 欧美 日韩 一区 |