case 1:
cout<<"开始登记学员信息..."<<endl;
enregister<stu>();
cout<<"登记完毕,请选择其他操作:";
goto lable;
case 2:
cout<<"开始查找所需学员..."<<endl;
findstudent<stu>();
cout<<"查找完毕,请选择其他操作:";
goto lable;
case 3:
cout<<"打印学生的成绩单..."<<endl;
print<stu>();
cout<<"修改完毕,请选择其他操作:";
goto lable;
case 4:
cout<<"进行修改,插入学员..."<<endl;
insert<stu>();
cout<<"修改完毕,请选择其他操作:";
goto lable;
case 5:
cout<<"清理已经登陆的学员信息..."<<endl;
deletestudent<stu>();
cout<<"清理完毕,请选择其他操作:";
goto lable;
case 6:
cout<<"将已登记的学员排序,请稍候..."<<endl;
inorder<stu>();
cout<<"排序完毕,请选择其他操作:";
goto lable;
case 7:
system("pause");
cout<<"退出本系统,欢迎下次使用,再见!!!"<<endl;
break;
default:
cout<<"输入字母错误,请重新输入:";
goto lable;
}
}
}
//头文件在这里 共两个 "cnode.h"和"need.h"
//cnode.h
#ifndef CIRCULAR_NODE_CLASS
#define CIRCULAR_NODE_CLASS
template <class T>
class CNode
{
private:
// circular link to the next node
CNode<T> *next;
public:
// data is public
T data;
// list modification methods
void InsertAfter(CNode<T> *p);
CNode<T> *DeleteAfter(void);
// obtain the address of the next node
CNode<T> *NextNode(void) const;
};
// constructor that creates an empty list and
// leaves the data uninitialized. use for header
template <class T>
CNode<T>::CNode(void)
{
// initialize the node so it points to itself
next = this;
}
// constructor that creates an empty list and initializes data
template <class T>
CNode<T>::CNode(const T& item)
{
// set node to point to itself and initialize data
next = this;
data = item;
}
// return pointer to the next node
template <class T>
CNode<T> *CNode<T>::NextNode(void) const
{
return next;
}
// insert a node p after the current one
template <class T>
void CNode<T>::InsertAfter(CNode<T> *p)
{
// p points to successor of the current node, and current node
// points to p.
p->next = next;
next = p;
}
// delete the node following current and return its address
template <class T>
CNode<T> *CNode<T>::DeleteAfter(void)
{
// save address of node to be deleted
CNode<T> *tempPtr = next;
// if next is the address of current object (this), we are
// pointing to ourself. We don't delete ourself! return NULL
if (next == this)
return NULL;
// current node points to successor of tempPtr.
next = tempPtr->next;
// return the pointer to the unlinked node
return tempPtr;
}
#endif // CIRCULAR_NODE_CLASS
\\cnode.h函数
#ifndef CIRCULAR_NODE_CLASS
#define CIRCULAR_NODE_CLASS
template <class T>
class CNode
{
private:
// circular link to the next node
CNode<T> *next;
public:
// data is public
T data;
// list modification methods
void InsertAfter(CNode<T> *p);
CNode<T> *DeleteAfter(void);
// obtain the address of the next node
CNode<T> *NextNode(void) const;
};
// constructor that creates an empty list and
// leaves the data uninitialized. use for header
template <class T>
CNode<T>::CNode(void)
{
// initialize the node so it points to itself
next = this;
}
// constructor that creates an empty list and initializes data
template <class T>
CNode<T>::CNode(const T& item)
{
// set node to point to itself and initialize data
next = this;
data = item;
}
// return pointer to the next node
template <class T>
CNode<T> *CNode<T>::NextNode(void) const
{
return next;
}
// insert a node p after the current one
template <class T>
void CNode<T>::InsertAfter(CNode<T> *p)
{
// p points to successor of the current node, and current node
// points to p.
p->next = next;
next = p;
}
// delete the node following current and return its address
template <class T>
CNode<T> *CNode<T>::DeleteAfter(void)
{
// save address of node to be deleted
CNode<T> *tempPtr = next;
// if next is the address of current object (this), we are
// pointing to ourself. We don't delete ourself! return NULL
if (next == this)
return NULL;
// current node points to successor of tempPtr.
next = tempPtr->next;
// return the pointer to the unlinked node
return tempPtr;
}
#endif // CIRCULAR_NODE_CLASS