• <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
            噜噜噜色噜噜噜久久| 久久国产AVJUST麻豆| 国产成人精品久久一区二区三区av | 亚洲狠狠久久综合一区77777| www.久久热.com| 久久精品草草草| 久久精品国产一区二区三区| 久久天天躁狠狠躁夜夜2020| 亚洲伊人久久综合影院| 欧美丰满熟妇BBB久久久| 久久精品一区二区三区不卡| 久久99精品久久久久久秒播| 久久这里只精品99re66| 国产亚洲精久久久久久无码| 久久午夜电影网| 热久久最新网站获取| 国产精品久久毛片完整版| 亚洲国产精品无码久久九九| 亚洲av成人无码久久精品| 国产精品成人久久久久久久| 久久久久亚洲AV无码观看| 久久国产乱子伦精品免费强| 久久无码专区国产精品发布| 国产精品18久久久久久vr| 性欧美大战久久久久久久| 久久精品国产91久久综合麻豆自制 | 久久精品国产亚洲AV无码麻豆 | 久久亚洲高清综合| 国产 亚洲 欧美 另类 久久| www.久久热| 69SEX久久精品国产麻豆| 欧洲精品久久久av无码电影| 久久99精品久久久大学生| 久久亚洲精品无码VA大香大香 | 奇米影视7777久久精品人人爽| 久久久久久无码国产精品中文字幕 | 久久国产精品免费一区二区三区| 国产精品无码久久久久久| 国产精品一区二区久久不卡| 欧美午夜精品久久久久免费视| 久久久久久久97|