• <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
            色妞色综合久久夜夜| 久久99精品国产麻豆蜜芽| 久久人人爽人人爽人人av东京热| 久久久久亚洲AV无码专区首JN| 亚洲va国产va天堂va久久| 色婷婷综合久久久久中文字幕 | 成人久久综合网| 久久久久亚洲精品日久生情| 人妻精品久久久久中文字幕69| 97久久精品人妻人人搡人人玩| 久久精品成人免费国产片小草| 99久久夜色精品国产网站| 日本高清无卡码一区二区久久| 热re99久久精品国99热| 狠狠精品干练久久久无码中文字幕| 久久人妻少妇嫩草AV蜜桃| 久久精品一区二区影院| 91精品国产乱码久久久久久 | 久久精品夜色噜噜亚洲A∨| 99久久99久久久精品齐齐| 国产成人综合久久精品红| 女人高潮久久久叫人喷水| 久久亚洲精品成人无码网站| 久久综合狠狠综合久久激情 | 久久天天躁狠狠躁夜夜96流白浆| 欧美一区二区久久精品| 伊人久久大香线蕉AV一区二区| 2021国内久久精品| 久久婷婷五月综合97色直播| 亚洲美日韩Av中文字幕无码久久久妻妇 | 99久久精品免费国产大片| 久久96国产精品久久久| 亚洲国产精品婷婷久久| 99热成人精品热久久669| 久久精品一本到99热免费| 99久久精品无码一区二区毛片 | 欧美粉嫩小泬久久久久久久| 99久久综合狠狠综合久久| 91久久精品电影| 深夜久久AAAAA级毛片免费看| 日本精品久久久久影院日本|