从链接列表中删除项目

时间:2013-04-07 21:30:47

标签: c++ list struct heap

struct node{
    int number;
    node *next;
    };
...
node* pOne;
node* pEnd;
// create node temp 
if( pOne==NULL)            // add temp in list
    pOne = temp;
    pEnd = temp;
else { 
    pEnd->next = temp;
    pEnd = temp;
} 

如果要从列表中删除项目该怎么办? 相邻元素是否改变了以下指针是明确的。 如何从内存中删除项目?

当它不链接时会收集垃圾收集器吗?

1 个答案:

答案 0 :(得分:0)

你必须自己从内存中释放它,看一下这个其他的stackoverflow答案

Does delete [] deallocate memory allocated by pointers to pointers

相关问题