各位帮帮看看,用delete删除一个链表时为什么会出错?在线等
struct MM
{
int count;
struct MM * next;
}
struct GG
{
int a;
struct MM * head;
}
void addnode(struct GG * gg)
{
struct MM * p1 = gg->head;
for(int i = 0; i < 11 ; i ++)
{
struct MM * p2 = new struct MM;
p1->next = p2;
p1 = p2;
}
}
void deletenode(strcut MM * mm)
{
if(mm->next != NULL)
deletenode(mm->next);
delete mm; // 在.net环境下说,用户未处理异常
}
程序只要运行到 最后一句就报错.