• <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>
            Operator new allocates memory from the heap, on which an object is constructed. Standard C++ also supports placement new operator, which constructs an object on a pre-allocated buffer. This is useful when building a memory pool, a garbage collector or simply when performance and exception safety are paramount (there's no danger of allocation failure since the memory has already been allocated, and constructing an object on a pre-allocated buffer takes less time):
             void placement() {

            char *buf = new char[1000]; //pre-allocated buffer

            string *p = new (buf) string("hi"); //placement new

            string *q = new string("hi"); //ordinary heap allocation

            cout<
            <
            c_str()
            <
            <c_str();

            }

            placement new 表達式只是定位,不存在與其相對應的delete,如果delete則選擇
            delete[] buf。


            michalegao 2008-06-05 12:03 發表評論

            文章來源:http://www.cnblogs.com/michael-gao/archive/2008/06/05/1214239.html
            Posted on 2008-06-05 15:59 micheal's tech 閱讀(252) 評論(0)  編輯 收藏 引用 所屬分類: C++ programme language
            一本大道久久东京热无码AV| 伊人久久大香线蕉综合5g| 国产精品久久久久久久久| 精品久久久久久久| 性做久久久久久免费观看| 国产精品美女久久久久| 久久久久久久综合综合狠狠| 99精品国产99久久久久久97| 国产精品美女久久久久av爽| 久久精品国产男包| 久久久久婷婷| 久久福利青草精品资源站免费| 亚洲国产成人久久综合野外| 伊人久久大香线焦综合四虎| 蜜臀久久99精品久久久久久小说| 欧美久久一级内射wwwwww.| 97精品久久天干天天天按摩| 精品久久久无码21p发布| 久久亚洲中文字幕精品一区| 7国产欧美日韩综合天堂中文久久久久 | 国产成人久久精品区一区二区| 久久久久久精品免费看SSS| 久久精品成人欧美大片| 久久精品国产91久久麻豆自制| 久久人与动人物a级毛片| 欧美午夜A∨大片久久| 欧美久久一区二区三区| 久久人人爽人人爽人人片AV东京热| 久久国产精品久久国产精品| 九九精品99久久久香蕉| 97精品国产91久久久久久| 粉嫩小泬无遮挡久久久久久| 久久精品国产亚洲av高清漫画| 国内精品久久久久影院亚洲| 久久久国产亚洲精品| 久久天天躁狠狠躁夜夜躁2014| 久久笫一福利免费导航 | 久久综合久久综合亚洲| 国产69精品久久久久9999APGF| 亚洲天堂久久久| 亚洲精品无码久久久久去q|