C++知识点[6]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 kind_li 的 blog

2、  指针在free delete后必须置为null

3、  指针的长度都为4字节

4、释放内存时,如果是数组指针,必须要释放掉所有的内存,如

char *p=new char[100];

strcpy(p,”hello world”);

delete []p;   //注意前面的[]号

p=null;

5、数组指针的内容不能超过数组指针的最大容易。

:

char *p=new char[5];

strcpy(p,”hello world”);  //报错  目标容易不够大

delete []p;   //注意前面的[]号

p=null;

 

十四、关于malloc/free new /delete

本文关键:C++ 知识点 入门
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top