如:CMyClass *temp;
CMyClass *temp1
temp = new CMyClass;
temp1 = new CMyClass;
...
temp = temp1;//此行会不会引发原temp所指对象的析构?换成如下三行之一,又如何?
temp1 = temp; temp = NULL;
CMyClass *temp2; temp2 = temp; temp = NULL;
temp = NULL;
谢谢.
CMyClass *temp1
temp = new CMyClass;
temp1 = new CMyClass;
...
temp = temp1;//此行会不会引发原temp所指对象的析构?换成如下三行之一,又如何?
temp1 = temp; temp = NULL;
CMyClass *temp2; temp2 = temp; temp = NULL;
temp = NULL;
谢谢.
CMyClass *temp1
temp = new CMyClass;
temp1 = new CMyClass;
...
temp = temp1;//不会引发原temp所指对象的析构仍然驻留在内存
把它的制改为NULL都没有用
你分配的CMyClass要这样才能释放 delete temp;