• <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   管理


            99热精品久久只有精品| 国产精品久久一区二区三区| 久久久久国产精品三级网 | 亚洲va久久久噜噜噜久久狠狠| 久久精品国产99久久无毒不卡| 婷婷久久综合九色综合98| 欧美精品福利视频一区二区三区久久久精品 | 国产精品久久久久久久久免费| 亚洲成人精品久久| 久久天天躁狠狠躁夜夜不卡| 青青热久久综合网伊人| 久久久久久伊人高潮影院| 国产伊人久久| 久久免费视频观看| 69SEX久久精品国产麻豆| 97香蕉久久夜色精品国产| 91麻豆精品国产91久久久久久| 色妞色综合久久夜夜| 久久精品中文字幕一区| 久久午夜无码鲁丝片午夜精品| 亚洲综合婷婷久久| 四虎国产精品免费久久久| 97久久天天综合色天天综合色hd | 欧美久久久久久| 国产精品久久网| www性久久久com| 99国产精品久久久久久久成人热| 亚洲国产精品18久久久久久| 囯产极品美女高潮无套久久久 | 综合久久一区二区三区| 性做久久久久久久久久久| 久久久久婷婷| 综合久久精品色| 久久久久se色偷偷亚洲精品av| 日本WV一本一道久久香蕉| 亚洲αv久久久噜噜噜噜噜| 亚洲乱码精品久久久久..| 久久永久免费人妻精品下载| 97久久精品人妻人人搡人人玩| 久久狠狠色狠狠色综合| 狠狠久久综合|