• <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久久精品国产高清一区二区| 国产精品欧美亚洲韩国日本久久| 伊人伊成久久人综合网777| 久久夜色精品国产网站| 精品久久久久一区二区三区| 欧美午夜A∨大片久久| 精品国产VA久久久久久久冰| 久久久久九国产精品| 久久久久久午夜成人影院| 久久综合伊人77777| 日本福利片国产午夜久久| 狠狠色婷婷久久综合频道日韩 | 久久亚洲国产成人精品无码区| 久久天天躁狠狠躁夜夜avapp| 伊人久久精品线影院| 久久夜色精品国产欧美乱| 亚洲欧美国产日韩综合久久| 女人香蕉久久**毛片精品| 久久久久久国产精品美女| 久久国产福利免费| 9191精品国产免费久久| 午夜久久久久久禁播电影| 武侠古典久久婷婷狼人伊人| 精品久久久久久久久久中文字幕| 97久久精品无码一区二区天美| 亚洲精品乱码久久久久久自慰 | 中文精品99久久国产| 国产免费福利体检区久久| 国产精品久久久天天影视| 国产精品美女久久久久久2018| 性色欲网站人妻丰满中文久久不卡 | 国产精品毛片久久久久久久| 久久久无码精品亚洲日韩蜜臀浪潮|