• <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
            狠狠色丁香婷婷久久综合五月| 一本大道久久香蕉成人网| 97久久精品人妻人人搡人人玩| 秋霞久久国产精品电影院| 久久无码人妻精品一区二区三区 | 久久99精品国产麻豆蜜芽| 久久久久久久国产免费看| 亚洲αv久久久噜噜噜噜噜| 国产成人精品久久亚洲| 777午夜精品久久av蜜臀| 99热都是精品久久久久久| 久久亚洲日韩看片无码| 国产成人无码精品久久久免费| 亚洲国产精品无码久久| 青青草国产97免久久费观看| 久久精品一区二区三区不卡| 中文字幕无码免费久久| 国产69精品久久久久99尤物| 精品久久人妻av中文字幕| 伊人 久久 精品| 青青草国产97免久久费观看| 亚洲精品高清国产一久久| 成人免费网站久久久| 亚洲va国产va天堂va久久| 久久精品国产2020| 久久国产AVJUST麻豆| 中文字幕精品无码久久久久久3D日动漫| 久久久久久久99精品免费观看| 久久久国产精品亚洲一区 | 国产精品女同久久久久电影院| yy6080久久| 99蜜桃臀久久久欧美精品网站| 人人妻久久人人澡人人爽人人精品| 亚洲国产成人乱码精品女人久久久不卡| 91精品国产91久久久久久蜜臀| 久久久久综合网久久| 国产福利电影一区二区三区久久久久成人精品综合 | 99麻豆久久久国产精品免费| 麻豆AV一区二区三区久久| 日产精品久久久久久久性色| 欧美一区二区三区久久综|