更新时间:2022-06-27 01:05:53
您的递归版本需要输入:
Your recursive version needs an input:
void List::PrintListRecursively(Node* curr)
{
if (curr==NULL)
{
cout << "
";
return;
}
cout << curr->data <<endl;
PrintListRecursively(curr->next);
}
然后你会使用头指针调用它:
Which you would then call using the head pointer:
list.PrintListRecursively(list.GetHead());
或者你可以创建一个不带参数的版本:
Or you could create a version that takes no parameters:
void List::PrintListRecursively()
{
PrintListRecursively(GetHead());
}
调用带指针参数的版本.
Which calls the version that takes the pointer parameter.