• <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精品伊人久久久大香线蕉 | yy6080久久| 国内精品久久久久国产盗摄| 久久99精品久久久久久野外 | 久久亚洲精品无码观看不卡| 欧美成a人片免费看久久| 国产成人无码精品久久久性色 | 久久久久久久尹人综合网亚洲 | 久久国产成人午夜aⅴ影院| 日本国产精品久久| 久久亚洲精品无码AV红樱桃| 94久久国产乱子伦精品免费| 天天躁日日躁狠狠久久| 国内精品久久久久久久coent | 久久久综合九色合综国产| 欧美粉嫩小泬久久久久久久 | 久久高潮一级毛片免费| 伊人久久精品无码av一区| 国产精品美女久久久网AV| 久久亚洲中文字幕精品有坂深雪| 久久97久久97精品免视看| 精品无码久久久久久午夜| 久久久午夜精品福利内容| 国产亚州精品女人久久久久久 | 亚洲国产天堂久久综合| 国产欧美久久久精品| 久久午夜免费视频| 国内精品久久久久久久影视麻豆| 成人综合伊人五月婷久久| 伊人色综合久久天天人手人婷| 久久久久久A亚洲欧洲AV冫| 久久精品国产亚洲精品2020| 亚洲国产成人精品91久久久| 久久―日本道色综合久久| 亚洲天堂久久久| 超级碰久久免费公开视频| 国产精品久久自在自线观看| 欧美午夜A∨大片久久 | 久久99热这里只有精品国产| 久久久久国产成人精品亚洲午夜| 狠狠久久亚洲欧美专区|