• <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国产精品久久99小说| 久久99九九国产免费看小说| 亚洲午夜福利精品久久| 91精品国产色综合久久| 欧洲性大片xxxxx久久久| 国产精品久久久久9999| 精品乱码久久久久久夜夜嗨| 亚洲AV无码久久精品狠狠爱浪潮| 欧美亚洲国产精品久久蜜芽| 久久久久这里只有精品| 欧美精品一本久久男人的天堂| 久久国产精品视频| 久久青青草原亚洲av无码app | 久久久亚洲AV波多野结衣| 国产高清国内精品福利99久久| 日韩精品久久久肉伦网站| 久久精品久久久久观看99水蜜桃| 国产精品免费看久久久| 国产偷久久久精品专区| 7777精品久久久大香线蕉| 国产69精品久久久久99| 久久66热人妻偷产精品9| 久久久久久久久久久| 精品国产乱码久久久久久浪潮| 人妻少妇久久中文字幕| 一本久久综合亚洲鲁鲁五月天| 99久久精品免费看国产一区二区三区| 久久免费高清视频| 亚洲AV日韩精品久久久久久久| 亚洲国产精品综合久久网络| 精品99久久aaa一级毛片| 91久久精品电影| 国产ww久久久久久久久久| 青青青青久久精品国产h| 久久精品国产亚洲综合色| 精品久久久久中文字幕一区| 久久香蕉国产线看观看乱码| 精品久久一区二区| 青青草国产成人久久91网| 国产精品成人99久久久久91gav|