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

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

        <legend id='Y5leX'><style id='Y5leX'><dir id='Y5leX'><q id='Y5leX'></q></dir></style></legend>

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

          <bdo id='Y5leX'></bdo><ul id='Y5leX'></ul>

      1. C++ catch 塊 - 按值或引用捕獲異常?

        C++ catch blocks - catch exception by value or reference?(C++ catch 塊 - 按值或引用捕獲異常?)

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

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

            <bdo id='vxbdL'></bdo><ul id='vxbdL'></ul>

                  <legend id='vxbdL'><style id='vxbdL'><dir id='vxbdL'><q id='vxbdL'></q></dir></style></legend>
                    <tbody id='vxbdL'></tbody>
                  本文介紹了C++ catch 塊 - 按值或引用捕獲異常?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  可能的重復(fù):
                  在 C++ 中通過指針捕獲異常

                  我總是按值捕獲異常.例如

                  I always catch exceptions by value. e.g

                  try{
                  ...
                  }
                  catch(CustomException e){
                  ...
                  }
                  

                  但我遇到了一些用 catch(CustomException &e) 代替的代碼.這是 a) 好的 b) 錯(cuò)誤的 c) 灰色區(qū)域嗎?

                  But I came across some code that instead had catch(CustomException &e) instead. Is this a)fine b)wrong c)a grey area?

                  推薦答案

                  C++ 中異常的標(biāo)準(zhǔn)做法是......

                  The standard practice for exceptions in C++ is ...

                  按值拋出,按引用捕獲

                  在繼承層次結(jié)構(gòu)面前,按值捕獲是有問題的.假設(shè)對(duì)于您的示例,還有另一種類型 MyException 繼承自 CustomException 并覆蓋錯(cuò)誤代碼等項(xiàng)目.如果拋出 MyException 類型,您的 catch 塊將導(dǎo)致它被轉(zhuǎn)換為一個(gè) CustomException 實(shí)例,這將導(dǎo)致錯(cuò)誤代碼發(fā)生變化.

                  Catching by value is problematic in the face of inheritance hierarchies. Suppose for your example that there is another type MyException which inherits from CustomException and overrides items like an error code. If a MyException type was thrown your catch block would cause it to be converted to a CustomException instance which would cause the error code to change.

                  這篇關(guān)于C++ catch 塊 - 按值或引用捕獲異常?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒有異常時(shí),C++ 異常會(huì)以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對(duì) const 的引用?)
                  When and how should I use exception handling?(我應(yīng)該何時(shí)以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對(duì)象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構(gòu)造函數(shù)的初始化列表中捕獲異常)
                  Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別)
                      <bdo id='hWgn3'></bdo><ul id='hWgn3'></ul>

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

                      1. <tfoot id='hWgn3'></tfoot>

                            <legend id='hWgn3'><style id='hWgn3'><dir id='hWgn3'><q id='hWgn3'></q></dir></style></legend>

                            主站蜘蛛池模板: 日韩中文字幕第一页 | 国产一级在线 | 蜜桃精品视频 | 精品一区二区三区四区 | 青青青草视频 | 国产免费91| 国产午夜一区二区三区 | 亚洲激情文学 | 久久激情小说 | 天天看天天干 | 天天网综合 | 天天视频黄 | 91伦理| 香蕉成人 | 亚洲视频在线播放 | 美国式禁忌14在线 | 成人在线免费视频观看 | 91丨九色丨蝌蚪丨丝袜 | 成人黄色录像 | 亚洲天天 | 亚洲一区二区久久 | 日韩中文字幕在线播放 | 成人免费网站黄 | 日本色网址 | 午夜高清 | 天堂中文av | 国产97视频 | 精品国产一二三区 | 日韩黄色大片 | 国产激情久久久 | 久在线视频| 亚洲精品在线观看视频 | 日韩免费看片 | 伊人久久中文字幕 | 国产免费久久 | 亚洲一区二区在线播放 | 国产福利91 | 一区二区高清视频 | 日韩va | 五月天激情综合网 | 成人国产精品视频 |