在delete currentnode的时候会出错是为什么呢
我想问下为什么
bool list2::listdelet(int i, node *elem)
{
node *currentnode = m_pNode;
node *prenode = NULL;
if (i < 0 || i>m_length)
{
return false;
}
for (int count = 0; count < i; count++)
{
prenode = currentnode;
currentnode = currentnode->next;
}
prenode->next = currentnode->next;
elem->data = currentnode->data;
delete currentnode;
m_length--;
return true;
}
我delete currentNode的时候会报错: