• <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
            国产成人精品三上悠亚久久| 久久青青草原综合伊人| 无码人妻久久一区二区三区免费| 欧美久久久久久| 97精品伊人久久大香线蕉app| 久久天天躁狠狠躁夜夜2020| 久久久久亚洲AV无码永不| 久久人妻少妇嫩草AV无码蜜桃| 欧美黑人激情性久久| 亚洲精品tv久久久久| 久久综合中文字幕| 欧美一区二区三区久久综合| 久久亚洲国产精品五月天婷| 久久er热视频在这里精品| 久久久久久伊人高潮影院| 久久国产免费| 天天久久狠狠色综合| 久久精品无码专区免费青青| 久久精品国产亚洲AV忘忧草18| 亚洲精品NV久久久久久久久久| 国产精品日韩深夜福利久久| 久久99久久99小草精品免视看| 久久精品无码一区二区无码| 欧美喷潮久久久XXXXx| 精品久久亚洲中文无码| 欧美久久久久久| 7777精品伊人久久久大香线蕉| 欧美大战日韩91综合一区婷婷久久青草 | 亚洲欧美日韩久久精品| 久久久久香蕉视频| 精品国产婷婷久久久| 久久本道久久综合伊人| 91久久香蕉国产熟女线看| 国产成人久久精品麻豆一区| 国内精品久久久久久久久电影网| 国产成人久久精品麻豆一区| 久久伊人亚洲AV无码网站| 亚洲?V乱码久久精品蜜桃| 中文成人久久久久影院免费观看| 午夜精品久久久久久| 伊人久久精品无码二区麻豆|