• <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永久一区二区三区久久 | 一级女性全黄久久生活片免费| 久久一本综合| 久久国产精品99精品国产| 狠狠人妻久久久久久综合蜜桃| 久久久国产99久久国产一| 精品久久久久久久无码 | 97精品依人久久久大香线蕉97| 久久ww精品w免费人成| 久久久综合香蕉尹人综合网| 亚洲AV无码久久寂寞少妇| 久久久久99精品成人片牛牛影视| 亚洲色欲久久久综合网东京热| 国产免费福利体检区久久| 久久国产免费观看精品3| 色综合久久夜色精品国产| 狠狠色丁香久久综合婷婷| 人妻无码精品久久亚瑟影视 | 日韩欧美亚洲综合久久| 久久久久国产亚洲AV麻豆| 久久国产免费观看精品| 亚洲综合精品香蕉久久网| 中文字幕精品久久| 亚洲国产日韩欧美久久| 一级做a爰片久久毛片16| 精品熟女少妇a∨免费久久| 久久午夜无码鲁丝片| 亚洲国产精品久久久天堂| 久久婷婷五月综合97色直播| 亚洲精品99久久久久中文字幕| 国内精品久久久久久久coent| 一级做a爰片久久毛片人呢| 国产精品狼人久久久久影院| 久久青青草原综合伊人| 99久久精品免费看国产| AA级片免费看视频久久| 久久精品无码一区二区三区日韩| 99久久国产亚洲高清观看2024| 国产成人无码精品久久久免费| 国产福利电影一区二区三区久久久久成人精品综合 |