why does not "g++ -Wall" give warning message when compiling the following code?
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 10 楼,当前显示第 7 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:icky (等级:15 - 最接近神,发帖:7923) 发表:2005-10-30 15:44:12  7楼 
delete array; not delete [] array;delete [] arr; is equivalant to delete arr[0]; delete arr[1]; ... delete arr[k]; ------------------------------------------------ defination from msdn: The delete operator destroys the object created with new by deallocating the memory associated with the object. ------------------------------------------------ however your array is array of primative type bool now try this Class Bool { public bool myBool; }; Bool *flag2 = new Bool[8]; delete [] flat2;
do u mean
"delete [] arr" deletes each cell
and
"delete arr" deletes the pointer itself

after "delete [] arr", the pointer "arr" still exists
This page is intentionally left blank
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 10 楼,当前显示第 7 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码