赞
踩
在C/C++中,当指针需要删除时,对于new的指针,调用delete就可以删除 比如 :
- int* p = new int(17);
- delete p;
- int* p = new int(17);
- delete p;
- p = NULL;
- int* p = new int(17);
- void deleteP(int* a){
- delete a;
- a = NULL;
- }
- if ( p != NULL)
- {
- .....
- }
- int* p = new int(17);
- void deleteP(int*& a){
- delete a;
- a = NULL;
- }
#define CC_SAFE_DELETE(p) if(p) { delete (p); (p) = NULL; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。