Implement the following client function which displays each item in a given list
ID: 3695143 • Letter: I
Question
Implement the following client function which displays each item in a given list on the computer screen.
(Note: Assume that each item in the list can be displayed by using std::cout << item.)
void DisplayList(UnsortedType list)
// Pre condition: list has been initialized.
// Post condition: Each item in list has been displayed on computer screen
Explanation / Answer
Answer:
The function which displays each item in a given list is given as below :
void DisplayList(UnsortedType list)
{
ItemType element;
int len;
list.ResetList();
len=list.GetLength();
for(int i=1;i<=len;i++)
{
list.GetNextItem(element);
element.Print();
}
}