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

            隨心動

            C++單件模式及內存釋放[轉載]

            轉載網址:http://blog.csdn.net/windboyzsj/article/details/2790485
             1 #include <iostream.h> 
             2 class Singleton 
             3 { 
             4 public
             5 ~Singleton(){cout<<"singleton deconstruct"<<endl;} 
             6 static Singleton* Instance() 
             7 { 
             8   if (_instance == NULL) 
             9   { 
            10    _instance = new Singleton(); 
            11    static Cleaner cl; //延遲到這里 
            12   } 
            13   return _instance; 
            14 } 
            15 void Print(char* str) 
            16 { 
            17   cout<<"singleton print:"<<str<<endl; 
            18 } 
            19 private
            20 Singleton(){cout<<"singleton construct"<<endl;} 
            21 static Singleton* _instance; 
            22 class Cleaner 
            23 { 
            24 public
            25   Cleaner(){cout<<"cleaner construct"<<endl;} 
            26   ~Cleaner() 
            27   { 
            28    cout<<"cleaner deconstruct"<<endl; 
            29    if(Singleton::Instance()) 
            30    delete Singleton::Instance(); 
            31   } 
            32 }; 
            33 }; 
            34 Singleton* Singleton::_instance = NULL; 
            35 int main(int argc, char* argv[]) 
            36 { 
            37 Singleton::Instance()->Print("print 1"); 
            38 Singleton::Instance()->Print("print 2"); 
            39 return 0; 
            40 }

            posted on 2013-12-17 04:18 陳志遠 閱讀(328) 評論(0)  編輯 收藏 引用

            導航

            <2013年12月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            統計

            常用鏈接

            留言簿

            隨筆檔案

            文章分類

            Othor's blog

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            99re久久精品国产首页2020| 伊人热热久久原色播放www | 亚洲精品无码久久久久| 中文字幕无码免费久久| 久久精品99久久香蕉国产色戒| 国内精品久久久久影院优| 99久久国产综合精品五月天喷水 | 久久综合给久久狠狠97色| 国产精品一区二区久久| 欧美色综合久久久久久| 久久人妻少妇嫩草AV无码专区| 秋霞久久国产精品电影院| 天天做夜夜做久久做狠狠| 久久亚洲欧美日本精品| 亚洲精品tv久久久久| 久久综合狠狠综合久久激情 | 免费精品国产日韩热久久| 99久久无码一区人妻a黑| 色诱久久av| 999久久久国产精品| 亚洲国产精品无码成人片久久| 久久久久女教师免费一区| www性久久久com| 久久偷看各类wc女厕嘘嘘| 亚洲欧美成人久久综合中文网| 九九久久精品国产| 久久国产精品-久久精品| 浪潮AV色综合久久天堂| 亚洲日韩中文无码久久| 无码8090精品久久一区| 久久综合视频网站| 亚洲欧美成人久久综合中文网| 精品久久久久久无码免费| 精品一久久香蕉国产线看播放| 日本久久久精品中文字幕| 国产精品久久99| 99久久精品久久久久久清纯| 久久青青草原精品影院| 色综合久久天天综合| 国产69精品久久久久9999| 久久久久18|