Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago