• <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
            久久亚洲精品无码AV红樱桃| 色综合久久中文综合网| 久久精品免费网站网| 99久久中文字幕| 精品久久人人做人人爽综合| 伊人色综合久久天天人守人婷| 久久久久av无码免费网| 久久婷婷国产麻豆91天堂| 色青青草原桃花久久综合| 久久精品国产99国产电影网| 国产激情久久久久影院老熟女| 亚洲乱码日产精品a级毛片久久| 91精品国产综合久久精品| 亚洲日韩欧美一区久久久久我 | 精品视频久久久久| 无码精品久久一区二区三区 | 狠狠色噜噜狠狠狠狠狠色综合久久 | 久久久久久精品免费看SSS | 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 伊人色综合久久天天人守人婷| 久久精品99久久香蕉国产色戒 | 久久香蕉国产线看观看99| 亚洲国产成人久久精品99| 人人狠狠综合久久亚洲88| 国内精品久久久久影院亚洲| 国产精品久久久久久久久久免费| 热re99久久精品国99热| 久久久久亚洲AV无码观看| 性做久久久久久免费观看| 国产精品内射久久久久欢欢| 波多野结衣中文字幕久久 | 国产精品久久久久影院嫩草| 伊人久久精品无码av一区 | 91精品国产综合久久香蕉| 国产一级做a爰片久久毛片| 久久综合九色综合网站 | 久久精品三级视频| 久久精品国产72国产精福利| 久久精品国产清自在天天线| 久久男人AV资源网站| 一本久道久久综合狠狠躁AV|