malloc free vs new delete

String * ptr_str = static_cast<String *>(3*malloc(sizeof(String)));
only Allocates the memory ;

String * ptr_str2 = new String[3];
calls the constructure of string class;

delete[]ptr;
if delete ptr only delte string[0]

 

posted on 2013-08-21 02:29  brave_bo  阅读(109)  评论(0)    收藏  举报

导航