• <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
            午夜精品久久久久久久久| 久久这里只有精品18| 久久综合九色综合久99| 久久综合给合久久国产免费| 99久久免费国产精精品| 超级碰久久免费公开视频| 人人狠狠综合88综合久久| 久久精品国产亚洲精品2020| 亚洲狠狠综合久久| 99久久夜色精品国产网站| 久久91精品国产91久久小草| 久久夜色精品国产www| 色综合久久无码五十路人妻| 久久99精品国产麻豆婷婷| 综合久久国产九一剧情麻豆| 色综合久久中文色婷婷| 久久精品国产久精国产果冻传媒| 久久99免费视频| 婷婷国产天堂久久综合五月| 69久久夜色精品国产69| 久久婷婷五月综合国产尤物app| 91久久成人免费| 久久精品www人人爽人人| 色偷偷91久久综合噜噜噜噜| 伊人久久大香线蕉精品| 久久久久亚洲精品无码蜜桃| 无码人妻久久一区二区三区蜜桃 | 久久久久久一区国产精品| 亚洲人成精品久久久久| 久久综合久久性久99毛片| 国产农村妇女毛片精品久久| www性久久久com| 精品少妇人妻av无码久久| 久久人人添人人爽添人人片牛牛 | 久久综合一区二区无码| 久久久九九有精品国产| 996久久国产精品线观看| 人妻丰满AV无码久久不卡| 伊人久久大香线蕉亚洲五月天 | 欧美伊香蕉久久综合类网站| 久久精品www人人爽人人|