• <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
            欧美精品一区二区精品久久| 久久国产成人| 久久亚洲日韩精品一区二区三区| 天天爽天天狠久久久综合麻豆| 久久久亚洲欧洲日产国码二区 | 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 亚洲国产精品一区二区三区久久| 久久国产精品无| 精品国产一区二区三区久久| 亚洲欧美日韩精品久久亚洲区| 久久亚洲精品无码AV红樱桃| 久久婷婷五月综合成人D啪| 久久久噜噜噜久久中文福利| 精品国产婷婷久久久| 午夜不卡久久精品无码免费| 国产午夜电影久久| 国产成人精品久久二区二区| 久久妇女高潮几次MBA| 国产精品嫩草影院久久| 久久精品中文騷妇女内射| 一日本道伊人久久综合影| 久久精品国产亚洲Aⅴ香蕉| 九九99精品久久久久久| 国产产无码乱码精品久久鸭| 狠狠综合久久综合88亚洲| 青青久久精品国产免费看| 久久精品国产WWW456C0M| Xx性欧美肥妇精品久久久久久| 996久久国产精品线观看| 久久婷婷国产综合精品 | 久久综合给合久久狠狠狠97色69| 久久婷婷午色综合夜啪| 亚洲国产成人久久精品99 | 久久国产乱子伦精品免费午夜| 久久精品国产亚洲麻豆| 精品国产福利久久久| 99久久99这里只有免费的精品| 亚洲av日韩精品久久久久久a| 亚洲色婷婷综合久久| 久久精品国产亚洲AV忘忧草18| 久久久久国产精品嫩草影院|