• <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
            久久国产影院| 91久久精品无码一区二区毛片| 无码乱码观看精品久久| 午夜视频久久久久一区| 色狠狠久久AV五月综合| 国产高清国内精品福利99久久| 久久人人爽人人爽人人片AV麻豆 | 香蕉久久夜色精品国产小说| 久久国产高清一区二区三区| 国产亚洲精久久久久久无码77777| 一本大道加勒比久久综合| 蜜桃麻豆WWW久久囤产精品| 国产成人久久精品区一区二区| 午夜视频久久久久一区| 日本免费久久久久久久网站 | 精品久久久久久久久中文字幕| 狠狠久久综合| 久久久青草久久久青草| 亚洲国产欧美国产综合久久| 欧美午夜A∨大片久久 | 久久国产综合精品五月天| 91精品国产高清91久久久久久| 国产精品久久婷婷六月丁香| 欧美午夜A∨大片久久| 久久电影网| 国产精品成人久久久久三级午夜电影 | 久久人与动人物a级毛片| 久久国产视频99电影| 国产精品免费久久| 国产成人99久久亚洲综合精品| 国产成人精品久久一区二区三区| 亚洲AV无码久久精品成人| 亚洲中文字幕久久精品无码喷水| 亚洲人AV永久一区二区三区久久| 欧美日韩精品久久久久 | 国产精品免费久久| 亚洲国产精品无码久久98| 婷婷五月深深久久精品| 亚洲av日韩精品久久久久久a| 久久久久人妻一区精品色| 久久久久亚洲AV成人片 |