• <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
            伊人色综合九久久天天蜜桃| 青青青青久久精品国产h| 久久99热国产这有精品| 热re99久久精品国99热| 97久久天天综合色天天综合色hd| 久久精品国产精品青草app| 国产精品免费久久久久电影网| 亚洲国产成人精品久久久国产成人一区二区三区综 | 性欧美丰满熟妇XXXX性久久久 | 久久福利青草精品资源站| 国内精品伊人久久久久网站| 久久久久噜噜噜亚洲熟女综合| 亚洲女久久久噜噜噜熟女| 蜜桃麻豆www久久| 老男人久久青草av高清| 国产精品久久久久久影院| 亚洲欧美久久久久9999| 久久综合久久综合九色| 久久久这里只有精品加勒比 | 久久人人爽人人爽人人片AV麻烦| 99精品国产在热久久无毒不卡| 亚洲а∨天堂久久精品9966| 久久精品国产99国产精偷| 久久久黄色大片| 久久久久99精品成人片三人毛片 | 狠狠久久综合伊人不卡| 人妻精品久久久久中文字幕一冢本| 精品国产91久久久久久久a| 999久久久无码国产精品| 久久99热这里只有精品国产| 理论片午午伦夜理片久久 | 久久综合狠狠综合久久| 欧美日韩久久中文字幕| 久久精品成人影院| 99久久99久久精品国产片| 国内精品伊人久久久久av一坑| 久久精品国产AV一区二区三区| 久久亚洲AV无码西西人体| 国产精品VIDEOSSEX久久发布| 91秦先生久久久久久久| 91精品国产高清久久久久久国产嫩草|