我想向链表后面添加一个元素,但它似乎没有添加,有人能告诉我什么是我的代码感谢谢谢。我的链接列表不为空添加元素到链表末尾时遇到问题
void LinkedList::Addelementfromback(VoidPtr horoscope)
{
NodePtr temp = head;
while (temp != NULL)
{
temp=temp->next;
}
NodePtr element=new Node;
element->data=horoscope;
element->next=NULL;
temp=element;
}
该功能有效地做什么都没有,除了泄漏的内存。 – chris
@chris非常有帮助谢谢,请向Pavel学习 – Computernerd
@Computernerd:这是没有办法与谁花时间,在周末免费,在周末阅读你的非问题,并检查你的代码给你的人。请向...学习......其他人。 –