帮忙改一下程序(内存泄露?)
template <class Type> void List<Type>::MergeList(List<Type>&Lb,List<Type>&Lc){ListNode<Type> *pa,*pb,*pc;
pa=first->NextNode();
pb=Lb.first->NextNode();
Lc.first=pc=first;
while(pa&&pb){
if(pa->GetData()<=pb->GetData()){
pc->link=pa;pc=pa;pa=pa->NextNode();
}else{
pc->link=pb;pc=pb;pb=pb->NextNode();
}
}
pc->link=pa?pa:pb;
delete Lb.first;
}
析构函数是这样的
template <class Type> void List<Type>::MakeEmpty()
{
ListNode<Type> *q;
while(first->link!=NULL){
q=first->link;first->link=q->link;
delete q;
}
last=first;
}
template <class Type> List<Type>::~List()
{
MakeEmpty();
delete first;
}