• <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| 国产农村妇女毛片精品久久| 国产精品亚洲综合久久| 亚洲天堂久久久| 久久国产精品一国产精品金尊| 久久国产精品成人影院| 欧美激情精品久久久久| 久久精品无码av| 一本一本久久aa综合精品| 久久99精品国产| 欧美一区二区久久精品| 久久国产色AV免费看| 精品久久久久久国产三级| 奇米影视7777久久精品人人爽| 亚洲成色www久久网站夜月 | 岛国搬运www久久| 一本一道久久a久久精品综合| 99精品国产在热久久| 日本WV一本一道久久香蕉| 国产精品久久亚洲不卡动漫| 三级三级久久三级久久 | 亚洲国产精品热久久| 成人久久免费网站| 韩国三级中文字幕hd久久精品| 青草国产精品久久久久久| 久久久久亚洲精品男人的天堂 | 久久久久久毛片免费看| 国产精品久久久久9999| 日韩精品久久无码中文字幕| 性做久久久久久久久久久| 国内精品久久久久久久久| 久久亚洲国产午夜精品理论片| 欧美黑人又粗又大久久久| 伊人久久精品影院| 模特私拍国产精品久久| 久久午夜综合久久| 女同久久| 色悠久久久久久久综合网| 久久久综合香蕉尹人综合网| 国产精自产拍久久久久久蜜| 久久青草国产精品一区|