Visual studio2022在运行以下程序时会在MakeEmpty函数处引发异常，请帮我修改#include<iostream>
#include<fstream>
#include <string>;
using namespace std;
class student {
	int id;
	string name;
	int score;
public:
	student(int i = 0, string n = "\0", int s = 0);
	void show();
	bool operator<(student stu);
	bool operator!=(student stu);
	void input(int i = 0, string n = "\0", int s = 0);
	friend ostream& operator<<(ostream& out, student stu);
	void operator=(const student stu);
	void putkey(int i) { id = i; };
};
void student:: operator=(const student stu) {
	id = stu.id;
	name = stu.name;
	score = stu.score;
}
ostream& operator<<(ostream& out, student stu) {
	out << stu.id << '\t' << stu.name << '\t' << stu.score << endl;
	return out;
}
void student::input(int i, string n, int s) {
	id = i;
	name = n;
	score = s;
}
student::student(int i, string n, int s) {
	id = i;
	name = n;
	score = s;
}
void student::show() {
	cout << "id= " << id << " name= " << name << " score= " << score << endl;
}
bool student:: operator<(student stu) {
	return(score < stu.score);
}
bool student:: operator!=(student stu) {
	return (id != stu.id);
}
template<typename T> class List;
template <typename T>class Node {
	T info;
	Node<T>* link;
public:
	Node();
	Node(const T& i);
	friend class List<T>;
};
template<typename T> Node<T>::Node() {
	link = NULL;
}
template<typename T>Node<T>::Node(const T& i) {
	info = i;
	link = NULL;
}
template<typename T>class List {
	Node<T>* head, * tail;
public:
	List();
	List(List& lis);
	~List();
	void MakeEmpty();
	Node<T>* CreatNode(T data);
	void InsertFront(Node<T>* p);
	void PrintList();
	void InsertRear(Node<T>* p);
	Node<T>* Find(T inf);
	Node<T>* DeleteNode(Node<T>* p);
	int Length();
	void InsertOrder(Node<T>* p);
	void Reverse();
};
template<typename T>void List<T>::Reverse() {
	Node<T>* temp , * p = head, *q=head->link;
	head->link = tail;
	while (tail != q) {
		temp = q;
		while (temp != tail) {
			p = temp;
			temp = temp->link;
		}
			tail->link = p;
			tail = p;
			tail->link = NULL;
	}
}
template<typename T>void List<T>::InsertOrder(Node<T>* p) {
	Node<T>* temp = head->link, * p2 = head;
	while (temp != NULL&& temp->info < p->info) {
		p2 = temp->link;
		temp = temp->link;
	}
	if (temp!=NULL&&p->info < temp->info) {
		p2->link = p;
		p->link = temp;
	}
	else {
		tail->link = p;
		tail = p;
		tail->link = NULL;
	}
}
template<typename T> int List<T>::Length() {
	int i = 0;
	Node<T>* temp = head->link;
	while (temp != 0) {
		i++;
		temp=temp->link;
	}
	return i;
}
template<typename T> Node<T>* List<T>::DeleteNode(Node<T>* p) {
	Node<T>* temp = head, *t=head;
	while (temp != NULL && temp->link != p) {
		t = temp->link;
		temp = temp->link;
	}
	if (temp->link == p) {
		t->link = p->link;
		delete p;
	}
	return head;
}
template<typename T> Node<T>* List<T>::Find(T inf) {
	Node<T>* temp = head->link;
	while (temp != NULL&&temp->info != inf)temp=temp->link;
	return temp;
}
template<typename T> void List<T>::PrintList() {
	Node<T>* temp = head->link;
	while (temp!= 0) {
		cout << temp->info;
		temp = temp->link;
	} 
	cout << endl;
}
template<typename T>void List<T>:: InsertRear(Node<T>* p){
		tail->link = p;
		tail = p;
		p->link = NULL;
}
template<typename T> void List<T>::InsertFront(Node<T>* p) {
	p->link = head->link;
	head->link = p;
	if (head == tail) tail = p;
}
template<typename T> Node<T>* List<T>::CreatNode(T data) {
	Node<T>* temp = new Node<T>(data);
	return temp;
}
/*template<typename T> List<T>::List(List<T>& lis) {
	head = tail = new Node<T>();
	Node<T>* iter = lis.head->link; // 原链表中的第一个结点
	while (iter != NULL) {
		Node<T>* newNode = new Node<T>(iter->info); // 复制原结点数据
		InsertRear(newNode); // 插入到新链表尾部
		iter = iter->link; // 遍历下一个结点
	}
}*/
template<typename T> List<T>::List(List<T>& lis) {
	head = tail = new Node<T>();
	Node<T>* temp = lis.head->link;
	while (temp != NULL) {
		Node<T>* pnew = CreatNode(temp->info);
		InsertFront(pnew);
		temp=temp->link;
	}
}
template<typename T> List<T>::List() {
	head = tail = new Node<T>();
}
template<typename T>void List<T>::MakeEmpty() {
	Node<T>* temp;
	while (head->link != NULL) {
		temp = head->link;
		head->link = temp->link;
		delete temp;
	}
	tail = head;
}
template<typename T>List<T>::~List() {
	if(head->link)MakeEmpty();
	delete head;
}

void  main() {
	student st;
	Node<student>* pnode;
	List <student> list1, list2;
	//读入文件中数据建立链表list1，list2;
	ifstream ifile;
	ifile.open("F:\\C++\\c++\\5 10\\studata.txt");
	int i, s;
	char n[10];
	while (ifile.eof() == 0) {
		ifile >> i >> n >> s;
		st.input(i, n, s);
		pnode = list1.CreatNode(st);
		list1.InsertFront(pnode);
	} 
	ifile.close();
	ifile.open("F:\\C++\\c++\\5 10\\studata.txt");
	while (ifile.eof() == 0) {
		ifile >> i >> n >> s;
		st.input(i, n, s);
		pnode = list2.CreatNode(st);
		list2.InsertRear(pnode);
	} 
	ifile.close();
	//list1，list2 建立成功，输出查看。
	list1.PrintList();
	list2.PrintList();
	cout << "用list构造list3\n";
	List <student> list3(list1);
	//拷贝构造函数先建立一个头结点，再以原链表的各结点的数据域来构造新链表的各对应结点。
	list3.PrintList();
	cout << "请输入删除结点的学号：\n";
	int number;
	cin >> number;
	st.putkey(number);
	pnode = list1.Find(st);

	if (pnode) {
		pnode = list1.DeleteNode(pnode);
		list1.PrintList();
		cout << "list1 长度：" << list1.Length() << endl;
	}
	else cout << "未找到！\n";

	cout << "清空list1，按分数从大到小的顺序重建list1" << endl;
	list1.MakeEmpty();

	ifile.clear(0);
	ifile.seekg(0);

	//读入文件数据，重建list1
	ifile.open("F:\\C++\\c++\\5 10\\studata.txt");
	while (ifile.eof() == 0) {
		ifile >> i >> n >> s;
		student st(i, n, s);
		pnode = list1.CreatNode(st);
		list1.InsertOrder(pnode);
	}
	list1.PrintList();
	ifile.close();
	cout << "将链表list1逆序\n";
	//要求不删除原结点，也不另建一个链表来取代，
	// 而是通过改变指针域的链接方向来逆转链表。

	list1.Reverse();
	list1.PrintList();

	cout << "用list3赋值给list1\n";
	list1 = list3;
	list1.PrintList();
}