Introduction - If you have any usage issues, please Google them yourself
template<class type>class LinkList
template<class type>
class Node
{
friend class LinkList<type> //定义类LinkList<type>为友元
Node <type>*next //结点的指针域
public:
virtual ~Node()
type data //数据域
Node(Node<type>*pnext=NULL) //构造函数,用于构造头结点
Node(const type &item,Node<type>*pnext=NULL) //构造函数,用于构造非头结点
void SetNext(Node<type>*p){next=p } //修改结点的next域
void SetData(type x){data=x } //修改结点的data域
}
template<class type>
Node<type>::~Node()
{
}
template<class type>
Node<type>::Node(Node<type>*pnext) //构造函数,用于构造头结点
{
next=pnext
}
template<class type>
Node<type>::Node(const type &item,Node<type>*pnext) //构造函数,用于构造非头结点
{
data=item
next=pnext
}