fishking00 2015-10-23 16:15 采纳率: 50%
浏览 1641
已采纳

我想知道这个单链表输入函数有什么错,总是跳出。。。

template
void TLinkList::Input()//input function
{TNode *current=m_first->next,*p;
T x,n;
cout<<"input the length of the list"< cin>>n;
for(int i=1;i<=n;i++)
{
cout<<"input the data of the no."< cin>>x;
p=new TNode(x);
p=current->next;
current=current->next;
}
current->next=NULL;
}

  • 写回答

5条回答 默认 最新

  • threenewbee 2015-10-23 16:18
    关注

    p=current->next;
    写反了
    current->next = p;

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?