C++建立单向链表链表头指针需要使用指针类型的引用参数?
struct Node
{int date; Node *next;};
void CreateList(Node *&head) //引用参数是表头指针
{
s=new Node;
cin>>s->data;
while(s->data!=0)
{if(head==NULL)head=s;
else p->next=s;
p=s;
s=new Node;
cin>>s->data;}
p->next-NULL;
delete s;
return;
}函数需要修改指针的内
原创
2011-04-26 13:12:00 ·
3440 阅读 ·
1 评论