2007-08-10
原来我一直在脱了裤子放屁啊 NULL指针可以直接delete哦
在某坛子里面逛 看到有些人再批
if( p == NULL ) delete p;
p = NULL;
很好奇的看了下去
原来 delete 和 free都是支持NULL指针的啊
if( p == NULL ) delete p;
p = NULL;
很好奇的看了下去
原来 delete 和 free都是支持NULL指针的啊
C99 7.20.3.2 The free function
The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs.
C++98 5.3.5 Delete
if the value of the operand of delete is the null pointer the operation has no effect.
The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs.
C++98 5.3.5 Delete
if the value of the operand of delete is the null pointer the operation has no effect.







评论排行榜