• <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++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
            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

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            欧美精品国产综合久久| 99久久国产综合精品成人影院| 久久久WWW免费人成精品| 国产精品99久久久久久宅男小说| 日韩欧美亚洲国产精品字幕久久久| 一本色道久久88精品综合| 久久99精品久久久久久齐齐| 香蕉久久一区二区不卡无毒影院| 欧美成a人片免费看久久| 久久强奷乱码老熟女网站| 久久久久久久97| 精品久久久久久综合日本| 国产精品久久毛片完整版| 国产精品福利一区二区久久| 欧美国产精品久久高清| 久久久久久免费一区二区三区| 国产成人久久精品一区二区三区 | 九九99精品久久久久久| 日日狠狠久久偷偷色综合免费| 精品久久久久久久久中文字幕| 久久精品国产亚洲AV不卡| 国产99久久久国产精品小说| 久久综合中文字幕| 99久久777色| 久久国产高潮流白浆免费观看| 久久婷婷五月综合色奶水99啪| 亚洲日韩欧美一区久久久久我| 久久国产免费直播| 久久福利资源国产精品999| 久久久国产精华液| 国产免费福利体检区久久| 久久久午夜精品福利内容| 色欲综合久久躁天天躁蜜桃| 精品少妇人妻av无码久久| 久久天天躁狠狠躁夜夜躁2014| 97精品伊人久久大香线蕉| 国内精品久久久久影院亚洲| 亚洲?V乱码久久精品蜜桃| 亚洲精品国产综合久久一线| 亚洲国产日韩综合久久精品| 久久天天躁夜夜躁狠狠躁2022|