• <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++博客 :: 首頁 :: 新隨筆 :: 聯(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

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


            久久人妻少妇嫩草AV无码蜜桃| 欧美丰满熟妇BBB久久久| 国产日产久久高清欧美一区| 国产亚洲美女精品久久久| 久久婷婷色综合一区二区| 亚洲国产精品无码久久一区二区 | 亚洲国产高清精品线久久 | 亚洲国产精品久久久天堂| 久久精品无码午夜福利理论片| 蜜桃麻豆www久久| 久久天天躁狠狠躁夜夜不卡| 久久99精品国产99久久| 久久九九久精品国产免费直播| 国产精品视频久久| 亚洲精品成人网久久久久久| jizzjizz国产精品久久| 欧美精品福利视频一区二区三区久久久精品 | 久久精品国产色蜜蜜麻豆| 色欲综合久久中文字幕网 | 亚洲中文精品久久久久久不卡| 一本伊大人香蕉久久网手机| 久久精品青青草原伊人| 久久伊人色| a级毛片无码兔费真人久久| 久久超碰97人人做人人爱| 亚洲精品乱码久久久久久不卡| 久久婷婷久久一区二区三区| 97久久国产露脸精品国产| 综合久久给合久久狠狠狠97色| 国产精品成人精品久久久| 97久久超碰国产精品2021| 久久精品国产亚洲AV无码麻豆| 精品久久久久久中文字幕大豆网| 久久一本综合| 无码8090精品久久一区| 女同久久| 久久人人爽人人爽人人片AV麻烦| 武侠古典久久婷婷狼人伊人| 天堂无码久久综合东京热| 无码人妻久久一区二区三区蜜桃| 天堂无码久久综合东京热|