• <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
            欧美精品丝袜久久久中文字幕| 亚洲午夜久久久影院| 久久久精品波多野结衣| 色综合久久88色综合天天 | 久久九九久精品国产免费直播| 久久国产亚洲高清观看| 国产精品欧美亚洲韩国日本久久| 精品久久久久久国产免费了| 亚洲色欲久久久综合网东京热| 狠狠狠色丁香婷婷综合久久五月| 久久久受www免费人成| 9久久9久久精品| 99精品国产99久久久久久97 | 久久人人爽人人爽人人片AV不 | 久久久久国产一区二区| 久久超乳爆乳中文字幕| 久久受www免费人成_看片中文| www.久久精品| 久久水蜜桃亚洲av无码精品麻豆| 日韩欧美亚洲综合久久影院Ds| 青青青国产精品国产精品久久久久| 中文字幕久久精品| 日韩久久久久中文字幕人妻| 91久久精品国产91性色也| 波多野结衣中文字幕久久| 伊人久久大香线蕉亚洲| 亚洲精品国产第一综合99久久| 精品久久久无码中文字幕| 久久久久四虎国产精品| 韩国无遮挡三级久久| 国产精品99久久精品| 乱亲女H秽乱长久久久| 色婷婷综合久久久久中文一区二区| 色婷婷狠狠久久综合五月| 久久人妻少妇嫩草AV无码蜜桃| 91精品国产91热久久久久福利| 久久精品中文字幕久久| 国产精品欧美久久久久无广告 | 久久香蕉一级毛片| 66精品综合久久久久久久| 久久久精品免费国产四虎|