1 #include <iostream>
2 using namespace std;
3
4 int _tmain(int argc, _TCHAR* argv[])
5 {
6 char *str = NULL;
7 str = new char[6];
8 strcpy(str,"hello");
9 delete str;
10 if (str != NULL)
11 {
12 strcpy(str,"world");
13 cout<<str<<endl;
14 }
15 return 0;
16 }
输入结果:world
delete 只是把把申请的那段内存释放掉,但是这个指针是没有改变的,所以delete掉后,你的str的值还是指向那段内存!