• <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 表達式只是定位,不存在與其相對應(yīng)的delete,如果delete則選擇
            delete[] buf。


            michalegao 2008-06-05 12:03 發(fā)表評論

            文章來源:http://www.cnblogs.com/michael-gao/archive/2008/06/05/1214239.html
            Posted on 2008-06-05 15:59 micheal's tech 閱讀(251) 評論(0)  編輯 收藏 引用 所屬分類: C++ programme language
            久久久久国产| 精品久久久久久国产| 精品久久久一二三区| 中文字幕热久久久久久久| 久久亚洲国产中v天仙www| 亚洲精品高清一二区久久| 久久精品国产亚洲AV香蕉| 国产精品久久自在自线观看| 亚洲国产天堂久久综合| 国产亚洲精品自在久久| 日韩va亚洲va欧美va久久| 久久这里只有精品18| 中文字幕无码久久人妻| 99热热久久这里只有精品68| 久久精品无码午夜福利理论片| 亚洲国产成人精品女人久久久| 久久综合中文字幕| 午夜天堂精品久久久久| 久久笫一福利免费导航| 久久久久久无码国产精品中文字幕 | 久久国产亚洲精品| 中文精品久久久久国产网址| 久久99国产综合精品女同| 久久久噜噜噜久久中文字幕色伊伊| 精品久久久无码中文字幕| 国产一区二区三区久久| 99久久久精品免费观看国产| 亚洲伊人久久大香线蕉综合图片| 亚洲&#228;v永久无码精品天堂久久 | 国产精品美女久久福利网站| 久久亚洲国产精品五月天婷| 99久久精品免费看国产免费| 久久精品成人免费看| 久久被窝电影亚洲爽爽爽| 99久久无码一区人妻a黑| av国内精品久久久久影院| 2021久久精品国产99国产精品| 国内精品久久久久影院日本| MM131亚洲国产美女久久| 久久综合欧美成人| 亚洲&#228;v永久无码精品天堂久久|