#include<iostream>
using namespace std;
template <class T>class LinkList;
template <class T>
class Node
{
private:
T data;
Node<T> *next;
public:
friend class LinkList<T>;
Node(T x,Node *y=NULL):data(x),next(y){}
};
template <class T>
class LinkList
{
private:
Node<T> *head;
public:
LinkList(T a=-1,Node<T> *b=NULL)
{
head=new Node<T>(a,b);
}
LinkList(const LinkList &L)
{
head=new Node<T>;
Node<T>* x=L.head;
while(x->next)
{
x=x->next;
}
}
void InitFormTail(T c)
{
Node<T>* p=head;
while(p->next)
p=p->next;
p->next=new Node<T>(c);
}
void InitFormTail(int a,T c)
{
Node<T> *p=head;
int x=1;
while(p->next && x<a){
p=p->next;
x++;
}
p->n
c++ 单链表创建
最新推荐文章于 2022-11-05 22:50:14 发布