單鏈表結點類的實現如下所示。
public class Node<T>
{
private T data; //數據域
private Node<T> next; //引用域
//構造器
public Node(T val, Node<T> p)
{
data = val;
next = p;
}
//構造器
public Node(Node<T> p)
{
next = p;
}
//構造器
public Node(T val)
{
data = val;
next = null;
}
//構造器
public Node()
{
data = default(T);
next = null;
}
//數據域屬性
public T Data
{
get
{
return data;
}
set
{
data = value;
}
}
//引用域屬性
public Node<T> Next
{
&n