• <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精品免费一区二区| 国产成人久久激情91| 久久综合伊人77777| 亚洲人AV永久一区二区三区久久| 久久久久国产亚洲AV麻豆| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 国产精品免费福利久久| 国产精品18久久久久久vr| 精品无码人妻久久久久久| 国产精品成人久久久| 精品综合久久久久久97超人| 久久久久九国产精品| 亚洲狠狠婷婷综合久久久久 | 亚洲∧v久久久无码精品| 国产美女久久久| 综合久久国产九一剧情麻豆| 72种姿势欧美久久久久大黄蕉| 久久久久综合中文字幕| 国产成人久久精品区一区二区| 久久精品视频一| 久久九九免费高清视频| 97超级碰碰碰久久久久| 久久无码国产专区精品| 久久99久久成人免费播放| 2022年国产精品久久久久| 亚洲中文字幕久久精品无码喷水| 久久99精品久久久久久9蜜桃| 久久亚洲精品成人av无码网站| 久久露脸国产精品| 久久久久亚洲AV无码专区桃色| 国产成人综合久久综合| 久久精品www人人爽人人| 久久狠狠爱亚洲综合影院| 天天影视色香欲综合久久| 久久亚洲2019中文字幕| 久久亚洲国产精品123区| 久久精品国产欧美日韩| 久久久久亚洲av毛片大| 精品久久久久久无码中文野结衣| 色综合合久久天天综合绕视看| 国产精品久久久久久影院 |