• <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久久人妻无码精品系列| 欧美成a人片免费看久久| 久久精品亚洲乱码伦伦中文| 亚洲国产精品狼友中文久久久| 久久久久久国产a免费观看黄色大片| 色妞色综合久久夜夜| 国产欧美一区二区久久| 久久综合伊人77777| 久久亚洲春色中文字幕久久久| 91麻精品国产91久久久久| 久久天天躁狠狠躁夜夜avapp| 久久久久无码精品国产不卡| 久久久综合香蕉尹人综合网| 性欧美丰满熟妇XXXX性久久久| 99精品伊人久久久大香线蕉| 午夜精品久久久久久久| 青春久久| 国产免费福利体检区久久| 日本精品久久久久久久久免费| 亚洲国产精品无码久久久蜜芽| 久久久WWW成人免费精品| 国产精品久久久久久福利漫画| 亚洲香蕉网久久综合影视| 久久精品亚洲福利| 国内精品伊人久久久久影院对白 | 1000部精品久久久久久久久| 久久夜色精品国产www| 99久久www免费人成精品| 久久99精品国产| 国产精品久久久久jk制服| 久久综合狠狠综合久久| 久久精品人人做人人爽电影| 久久久久无码精品| 久久性生大片免费观看性| 久久综合给合综合久久| 性做久久久久久久久久久| 狠狠色丁香久久婷婷综合图片| 婷婷久久五月天| 人妻无码中文久久久久专区| 久久99精品久久久久久久不卡|