链表类模板的主函数运行后怎么安全停止退出
C++清华大学郑莉版链表类模板的主函数运行后怎么安全停止退出? 我按书上代码敲的…(头文件和实现都是按书上代码的)
附主函数:
附主函数:
#include<iostream>
#include"LinkedList.h"
using namespace std;
int main(){
LinkedList<int>list;
for(int i=0;i<10;i++){
int item;
cin>>item;
list.insertFront(item);
}
cout<<"输出链表:"<<endl;
list.reset();
while(!list.endOfList()){
cout<<list.data()<<" ";
list.next();
}
cout<<endl;
int key;
cout<<"输入删掉的元素:";
cin>>key;
list.reset();
while(!list.endOfList()){
if(list.data()==key)
list.deleteCurrent();
list.next();
}
cout<<"输出链表:"<<endl;
list.reset();
while(!list.endOfList()){
cout<<list.data()<<" ";
list.next();
}
cout<<endl;
list.clear();
list.reset();
while(!list.endOfList()){
cout<<list.data()<<" ";
list.next();
}
return 0;
}
#C/C++#