myclass() {Dbg("myclass constructed : %x\n", this);}
~myclass() {Dbg("myclass destroyed : %x\n", this);}
};
function1()
{
myclass * pt;
pt = new myclass[3];
delete[] pt;
return 0;
}
modified from http://www.cplusplus.com/reference/std/new/operator%20delete[]/
Debug 결과 (pt = 0x004229f4 일때)
myclass constructed : 4229f4
myclass constructed : 4229f5
myclass constructed : 4229f6
myclass destroyed : 4229f6
myclass destroyed : 4229f5
myclass destroyed : 4229f4
delete operator만 쓰면 당연 에러..
댓글 없음:
댓글 쓰기