//PROTOYPE
void Display();
//CALL
list.Display();
/***********************************
* Print the contents of the list *
***********************************/
void EmployeeList::Display()
{
// Temporary pointer
newEmployee * tmp;
tmp = head;
// No employees in the list
if(tmp == NULL)
{
cout << "\n\n\t\t***THERE IS NO EMPLOYEE INFORMATION STORED YET***\n";
return;
}
cout << "\n\n"
<< "\t\t************************************************\n"
<< "\t\t* Employee IDs and Yearly Salary DataBase *\n"
<< "\t\t************************************************\n\n";
cout << "\t\t\tEmployee IDs" << setw(20) << right << "Yearly Salaries\n";
// One employee in the list
if(tmp->Next() == NULL)
{
cout << "\t\t\t " << tmp->empID() << setw(13) << right << " "
<< "$" << setw(2) << tmp->ySalary() << endl;
}
else
{
do
{
cout << "\t\t\t " << tmp->empID() << setw(13) << " "
<< right << "$" << setw(2) << tmp->ySalary() << endl;
tmp = tmp->Next();
}while(tmp != NULL);
cout << "\n\t\t\t ***Thank You***" << endl;
}
}
我需要帮助写什么以便为Display函数执行递归函数调用。 我需要按照从倒数到倒数的顺序显示列表。 如何使用类链接列表进行递归打印?如何使用类链接列表执行递归打印
首先:不喊吧。请提供[MCVE]。 –
我可以听到你好 –
为什么你需要使用*递归*函数调用?一个简单的循环就足够了,你已经有了。至于按相反顺序打印,你的节点是否有一个'Previous()'方法来实现这一点?否则,只需将节点指针复制到向后排序的新列表中,然后再打印。 –