fireseed(Creamdog),你错在用sizeof不是时候啊。请看MSDN的解释: 先看sizeof的解释: The sizeof operator cannot return the size of dynamically allocated arrays or external arrays. 再看new的解释: The new operator attempts to dynamically allocate (at run time) one or more objects of type-name. 另: newkoala(洪(先生),珠海) new并没有错,你不信看看p下面是不是有8个相同的汉字,即8 * 2 =16个字节了。
#ifdef _DEBUG
#define new DEBUG_NEW
//////////////////////////Creamdog/////////////////////////////怎么会是16?你是用sizeof(p)吧?一个指针变量是一个int型,长度为4。
你测得的长度是多少?
先看sizeof的解释:
The sizeof operator cannot return the size of dynamically allocated arrays or external arrays.
再看new的解释:
The new operator attempts to dynamically allocate (at run time) one or more objects of type-name. 另:
newkoala(洪(先生),珠海)
new并没有错,你不信看看p下面是不是有8个相同的汉字,即8 * 2 =16个字节了。