这段代码有什么问题?调试后出现错误runner = runner->next;
,但我看不出它有什么问题。
void Linkedlist<T>::add(T item)
{
if (root == 0)
{
root = new Node<T>(item);
cout << "Add, Root is empty \n";
}
else
{
cout << "Add, Root is not empty \n";
Node<T> * runner = root;
while (runner != 0)
{
runner = runner->next;
}
runner = new Node<T>(item);
}
}