Question: I need to implement in c++ this non-List member function: void printList(List& theList, bool forward) is a non-member function that prints a list either forwards

I need to implement in c++ this non-List member function: void printList(List& theList, bool forward) is a non-member function that prints a list either forwards (by default -- from head to tail) when forward is true, or backwards (from tail to head) when forward is false. You must use your ListItr class to implement this function.

I attached my ListItr class I'm not sure how to implement this method help. This is one of the classes needed to implement a doubly linked list

#include "ListItr.h" #include  using namespace std; ListItr:: ListItr(ListNode* theNode){ current = theNode; } bool ListItr:: isPastEnd() const{ if (current->next==NULL) return true; else return false; } bool ListItr:: isPastBeginning() const{ if (current->previous==NULL) return true; else return false; } void ListItr:: moveForward(){ if (!isPastEnd()) current=current->next; cout << current; } void ListItr:: moveBackward(){ if (!isPastBeginning()) current=current->previous; cout << current; } int ListItr:: retrieve() const{ return current->value; } void printList(List& theList, bool forward){ // if(forward==true){ // moveForward(); // } // if(forward == false){ // moveBackward(); // } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!