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

            Zero Lee的專欄

            Life scope of one object example

            Example code:
             1 class A {
             2 public:
             3     A(int i) {
             4         if (i!=1) {
             5             std::vector<int> a;
             6             a.at(0= 1;
             7         } else
             8             std::cout << "ctor ok." << std::endl;
             9     }
            10     ~A() {
            11         std::cout << "A:dtor." << std::endl;
            12     }
            13 };
            14 
            15 void f()
            16 {
            17     try {
            18         A a(1);
            19         a.~A();
            20         new (&a) A(2);  /* here, throw one exception, but still destroy a again  */
            21     } catch() {
            22         std::cout << "catch exception." << std::endl;
            23     }
            24 }
            25 

            Above code snippet, if in placement new call, constructor of one class throws one exception, that a will still be destroyed again, since a is one automatic object, according to Cpp standard. In this case, one object constructed once, but destroyed twice, undefined/unpredicated behavior may happen.


            posted on 2010-12-03 14:48 Zero Lee 閱讀(220) 評論(0)  編輯 收藏 引用 所屬分類: CC++ Programming

            亚洲精品高清国产一线久久| 久久w5ww成w人免费| 国产精品99久久不卡| 久久久无码精品午夜| 人妻无码αv中文字幕久久琪琪布| 亚洲国产成人精品91久久久 | 久久这里有精品| 亚洲精品白浆高清久久久久久| 久久噜噜电影你懂的| 伊人伊成久久人综合网777| 成人久久综合网| 久久久久久久91精品免费观看| 国产成人精品久久免费动漫| 久久久久99精品成人片| 久久婷婷五月综合97色| 欧美激情精品久久久久久久| 99久久中文字幕| 亚洲va中文字幕无码久久| 久久99精品久久久久久秒播| 97久久国产露脸精品国产| 中文字幕久久精品| 亚洲精品高清久久| 国产成人精品久久免费动漫| 国产aⅴ激情无码久久| 久久无码人妻精品一区二区三区| 久久国产精品无码一区二区三区| 精品国产日韩久久亚洲| 99久久综合狠狠综合久久| 国产精品久久影院| 国产精品久久久久久久久| 一本久久知道综合久久| 亚洲中文字幕伊人久久无码| 久久狠狠一本精品综合网| 99久久精品国产毛片| 亚洲精品国产成人99久久| 99国产精品久久| 国产一区二区三区久久精品| avtt天堂网久久精品| 久久夜色精品国产噜噜噜亚洲AV| 狠狠精品久久久无码中文字幕| 久久人与动人物a级毛片|