• <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>
            posts - 9, comments - 0, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理
            Depending on the precise conditions under which such pairs of simultaneously active exceptions arise, program execution either terminates or yields undefined behavior. In this example, it yields undefined behavior.
            C++ does not like destructors that emit exceptions!
            #include <iostream>
            #include <vector>
            struct Exception
            {
                Exception(){std::cout << "Exception Constructor" << std::endl;}
                ~Exception(){std::cout << "Exception Destructor" << std::endl;}
            };
            class Widget {
            public:
              ~Widget() {std::cout << "Widget Destructor" << std::endl; throw Exception();
              }        //this might emit an exception
              void print(){std::cout << "print" << std::endl;}
            };
                            
            void doSomething();
            int main()
            {
                doSomething();
            }
            void doSomething()
            {
              std::vector<Widget> v;
              v.push_back(Widget());
              v.push_back(Widget());
              v.push_back(Widget());
              v.push_back(Widget());
              std::vector<Widget>::iterator it = v.begin();
              while(it != v.end())
              {
                std::cout << "end" << std::endl;
                (*it).print();
                it++;
              }
            }
            complie with g++
            [shangtang@BTSOM-1 study]$ ./a.out
            Widget Destructor
            Exception Constructor
            terminate called after throwing an instance of 'Exception'
            Aborted (core dumped)
            There are two primary ways to avoid the trouble.

               1, Terminate the program if catch a exception, typically by calling std::abort (cstdlib)
              2, 
            Swallow the exception if catch a exception, print a log
            777久久精品一区二区三区无码| 久久青青草原亚洲av无码app| 人人狠狠综合久久亚洲88| 97精品伊人久久久大香线蕉| 久久精品成人免费观看97| 理论片午午伦夜理片久久 | 久久精品国产亚洲av日韩 | 久久毛片一区二区| 国产美女久久精品香蕉69| 亚州日韩精品专区久久久| 色婷婷综合久久久久中文一区二区| 91精品国产综合久久香蕉| 亚洲国产另类久久久精品| 国产精品va久久久久久久| 久久久久AV综合网成人| 伊人 久久 精品| 久久婷婷色综合一区二区| 国产成人久久AV免费| 久久精品免费全国观看国产| 精品久久人人做人人爽综合| 久久婷婷激情综合色综合俺也去 | 99久久精品日本一区二区免费| 久久久久无码国产精品不卡| 青青青国产精品国产精品久久久久 | 久久综合久久综合九色| 久久无码国产专区精品| 天天综合久久一二三区| 久久成人国产精品一区二区| 97久久香蕉国产线看观看| 三上悠亚久久精品| 亚洲欧美日韩中文久久| 伊人色综合久久天天人手人婷| 亚洲国产成人久久综合一区77| 欧美久久亚洲精品| 久久综合久久综合亚洲| 久久伊人精品一区二区三区| 久久99热这里只频精品6| 2019久久久高清456| 狠狠色婷婷久久综合频道日韩| 伊人久久综合成人网| 久久国产精品-国产精品|