• <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精品久久久久久动态图| 久久亚洲高清观看| 久久人人爽人人精品视频| 久久综合亚洲色HEZYO社区| 亚洲女久久久噜噜噜熟女| 亚洲国产二区三区久久| 午夜精品久久久久9999高清| 久久人人爽人人爽人人片AV不| 中文字幕成人精品久久不卡| yy6080久久| 国产三级观看久久| 婷婷久久久亚洲欧洲日产国码AV| 国产综合免费精品久久久| 亚洲精品tv久久久久久久久| 久久久久久毛片免费看| 伊人久久大香线蕉影院95| 久久人爽人人爽人人片AV| 亚洲欧美精品一区久久中文字幕| 成人国内精品久久久久一区| 国产精品99久久久精品无码| 狠狠人妻久久久久久综合蜜桃| 亚洲级αV无码毛片久久精品| 久久亚洲精品无码观看不卡| 99久久无色码中文字幕| 久久精品蜜芽亚洲国产AV| 久久99热这里只有精品国产| 亚洲&#228;v永久无码精品天堂久久| 精品久久久久久无码专区 | 人妻丰满?V无码久久不卡| 亚洲AV无码一区东京热久久| 欧美日韩精品久久免费| 久久青青草视频| 一级做a爰片久久毛片免费陪| 久久毛片免费看一区二区三区| 中文字幕亚洲综合久久| 国产亚洲成人久久| 热久久国产欧美一区二区精品| 四虎影视久久久免费观看| 亚洲午夜无码久久久久小说| 亚洲国产精品成人AV无码久久综合影院|