SlideShare a Scribd company logo
1 of 4
Download to read offline
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
Solution
#ifndef LISTITR_H
#define LISTITR_H
#include
#include "stdafx.h"
// This is the content of the .h file, which is where the declarations go
class ListNode{
public:
ListNode* previous;
int value;
ListNode* next;
ListNode();
};
class ListItr {
public:
ListNode* current;
ListItr(ListNode* theNode);
void Insert(int value) const;
bool isPastEnd() const;
bool isPastBeginning() const;
void moveForward() ;
void moveBackward() ;
int retrieve() const;
};
// This is the end of the header guard
#endif
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include
#include
#include
#include "ListItr.h"
// TODO: reference additional headers your program requires here
#include "stdafx.h"
/*
for this first you need a class named ListNode
*/
using namespace std;
ListNode::ListNode()
{
previous=NULL;
next=NULL;
}
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 ListItr::Insert(int value) const{
ListNode* theNode;
theNode->value=value;
while(!isPastEnd())
{
moveForward();
}//loop ends when current-> next is null
current->next = theNode;//inserts value at the end of the list
theNode->previous=current;//defines previous pointer
theNode->next=NULL;//defines next pointer
}
//Startnode is the first node of the list
void printList(ListNode* Startnode, bool forward){
// if(forward==true){
// moveForward();
// }
// if(forward == false){
// moveBackward();
// }
//object of class ListItr
ListItr list(Startnode);
if(forward==true)
{
while(!list.isPastEnd())
{
cout<

More Related Content

Similar to I need to implement in c++ this non-List member function void print.pdf

I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfarpitcomputronics
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfmaheshkumar12354
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
 
In C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdfIn C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdffantoosh1
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdfaathmaproducts
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdfaathiauto
 
Applying Generics
Applying GenericsApplying Generics
Applying GenericsBharat17485
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfrajkumarm401
 
Javathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdfJavathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdfeyelineoptics
 
Write a java class LIST that outputsmainpublic class Ass.pdf
Write a java class LIST that outputsmainpublic class Ass.pdfWrite a java class LIST that outputsmainpublic class Ass.pdf
Write a java class LIST that outputsmainpublic class Ass.pdfebrahimbadushata00
 
helpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdfhelpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdfalmonardfans
 
Im creating a skip list program for my Algorithms and Advanced Data.pdf
Im creating a skip list program for my Algorithms and Advanced Data.pdfIm creating a skip list program for my Algorithms and Advanced Data.pdf
Im creating a skip list program for my Algorithms and Advanced Data.pdfarkmuzikllc
 
Linked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfLinked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfadityacomputers001
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfaashisha5
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfmallik3000
 
(Unordered Sets) As explained in this chapter, a set is a collection.pdf
(Unordered Sets) As explained in this chapter, a set is a collection.pdf(Unordered Sets) As explained in this chapter, a set is a collection.pdf
(Unordered Sets) As explained in this chapter, a set is a collection.pdfssuserc77a341
 
Write a method expand that could be added to the LinkedlntList class f.docx
Write a method expand that could be added to the LinkedlntList class f.docxWrite a method expand that could be added to the LinkedlntList class f.docx
Write a method expand that could be added to the LinkedlntList class f.docxnoreendchesterton753
 
Write a method expand that could be added to the LinkedlntList class .docx
 Write a method expand that could be added to the LinkedlntList class .docx Write a method expand that could be added to the LinkedlntList class .docx
Write a method expand that could be added to the LinkedlntList class .docxajoy21
 

Similar to I need to implement in c++ this non-List member function void print.pdf (20)

I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdf
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdf
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
 
In C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdfIn C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdf
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
 
Applying Generics
Applying GenericsApplying Generics
Applying Generics
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
 
Javathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdfJavathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdf
 
Write a java class LIST that outputsmainpublic class Ass.pdf
Write a java class LIST that outputsmainpublic class Ass.pdfWrite a java class LIST that outputsmainpublic class Ass.pdf
Write a java class LIST that outputsmainpublic class Ass.pdf
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
helpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdfhelpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdf
 
Im creating a skip list program for my Algorithms and Advanced Data.pdf
Im creating a skip list program for my Algorithms and Advanced Data.pdfIm creating a skip list program for my Algorithms and Advanced Data.pdf
Im creating a skip list program for my Algorithms and Advanced Data.pdf
 
강의자료7
강의자료7강의자료7
강의자료7
 
Linked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfLinked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdf
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdf
 
(Unordered Sets) As explained in this chapter, a set is a collection.pdf
(Unordered Sets) As explained in this chapter, a set is a collection.pdf(Unordered Sets) As explained in this chapter, a set is a collection.pdf
(Unordered Sets) As explained in this chapter, a set is a collection.pdf
 
Write a method expand that could be added to the LinkedlntList class f.docx
Write a method expand that could be added to the LinkedlntList class f.docxWrite a method expand that could be added to the LinkedlntList class f.docx
Write a method expand that could be added to the LinkedlntList class f.docx
 
Write a method expand that could be added to the LinkedlntList class .docx
 Write a method expand that could be added to the LinkedlntList class .docx Write a method expand that could be added to the LinkedlntList class .docx
Write a method expand that could be added to the LinkedlntList class .docx
 

More from FORTUNE2505

Why would a manager be concerned with bandwidth How is bandwidth me.pdf
Why would a manager be concerned with bandwidth How is bandwidth me.pdfWhy would a manager be concerned with bandwidth How is bandwidth me.pdf
Why would a manager be concerned with bandwidth How is bandwidth me.pdfFORTUNE2505
 
Where would the Internet be today if the UNIX operating system did n.pdf
Where would the Internet be today if the UNIX operating system did n.pdfWhere would the Internet be today if the UNIX operating system did n.pdf
Where would the Internet be today if the UNIX operating system did n.pdfFORTUNE2505
 
What do you understand by degrees of Data AbstractionSolution.pdf
What do you understand by degrees of Data AbstractionSolution.pdfWhat do you understand by degrees of Data AbstractionSolution.pdf
What do you understand by degrees of Data AbstractionSolution.pdfFORTUNE2505
 
validity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdf
validity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdfvalidity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdf
validity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdfFORTUNE2505
 
Twitter had their IPO in 2013. Which of the following is not accurate.pdf
Twitter had their IPO in 2013. Which of the following is not accurate.pdfTwitter had their IPO in 2013. Which of the following is not accurate.pdf
Twitter had their IPO in 2013. Which of the following is not accurate.pdfFORTUNE2505
 
Use C programmingMake sure everything works only upload.pdf
Use C programmingMake sure everything works only upload.pdfUse C programmingMake sure everything works only upload.pdf
Use C programmingMake sure everything works only upload.pdfFORTUNE2505
 
The Adventures of Huckleberry Finn was published twenty years after .pdf
The Adventures of Huckleberry Finn was published twenty years after .pdfThe Adventures of Huckleberry Finn was published twenty years after .pdf
The Adventures of Huckleberry Finn was published twenty years after .pdfFORTUNE2505
 
Step 1 You work for Thunderduck Custom Tables Inc. This is the first.pdf
Step 1 You work for Thunderduck Custom Tables Inc. This is the first.pdfStep 1 You work for Thunderduck Custom Tables Inc. This is the first.pdf
Step 1 You work for Thunderduck Custom Tables Inc. This is the first.pdfFORTUNE2505
 
Researchers argue about whether Oldowan toolmakers were hunters or s.pdf
Researchers argue about whether Oldowan toolmakers were hunters or s.pdfResearchers argue about whether Oldowan toolmakers were hunters or s.pdf
Researchers argue about whether Oldowan toolmakers were hunters or s.pdfFORTUNE2505
 
In Aristotles Poetics he speaks of epics and tragedies. How do.pdf
In Aristotles Poetics he speaks of epics and tragedies. How do.pdfIn Aristotles Poetics he speaks of epics and tragedies. How do.pdf
In Aristotles Poetics he speaks of epics and tragedies. How do.pdfFORTUNE2505
 
Name the type of chemical messenger is released from the axon termina.pdf
Name the type of chemical messenger is released from the axon termina.pdfName the type of chemical messenger is released from the axon termina.pdf
Name the type of chemical messenger is released from the axon termina.pdfFORTUNE2505
 
Marilee Jones, the former dean of admissions of the Massachusetts In.pdf
Marilee Jones, the former dean of admissions of the Massachusetts In.pdfMarilee Jones, the former dean of admissions of the Massachusetts In.pdf
Marilee Jones, the former dean of admissions of the Massachusetts In.pdfFORTUNE2505
 
Know how the complement of mRNAs in a cell can be assayed (in plants.pdf
Know how the complement of mRNAs in a cell can be assayed (in plants.pdfKnow how the complement of mRNAs in a cell can be assayed (in plants.pdf
Know how the complement of mRNAs in a cell can be assayed (in plants.pdfFORTUNE2505
 
In Module 5 the you are here slide indicates we are currently in.pdf
In Module 5 the you are here slide indicates we are currently in.pdfIn Module 5 the you are here slide indicates we are currently in.pdf
In Module 5 the you are here slide indicates we are currently in.pdfFORTUNE2505
 
Identify the role you believe mobile devices have on email investiga.pdf
Identify the role you believe mobile devices have on email investiga.pdfIdentify the role you believe mobile devices have on email investiga.pdf
Identify the role you believe mobile devices have on email investiga.pdfFORTUNE2505
 
I have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdfI have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdfFORTUNE2505
 
4. Real gross domestic prodact A. measures the value of fimal goods a.pdf
4. Real gross domestic prodact A. measures the value of fimal goods a.pdf4. Real gross domestic prodact A. measures the value of fimal goods a.pdf
4. Real gross domestic prodact A. measures the value of fimal goods a.pdfFORTUNE2505
 
Hypothesis What is your hypothesis for the genetic characteristi.pdf
Hypothesis  What is your hypothesis for the genetic characteristi.pdfHypothesis  What is your hypothesis for the genetic characteristi.pdf
Hypothesis What is your hypothesis for the genetic characteristi.pdfFORTUNE2505
 
How is a process shown in a DFD(data flow diagramSolution Data.pdf
How is a process shown in a DFD(data flow diagramSolution  Data.pdfHow is a process shown in a DFD(data flow diagramSolution  Data.pdf
How is a process shown in a DFD(data flow diagramSolution Data.pdfFORTUNE2505
 
Hey,Why is it not possible in Java to write a swap routine that sw.pdf
Hey,Why is it not possible in Java to write a swap routine that sw.pdfHey,Why is it not possible in Java to write a swap routine that sw.pdf
Hey,Why is it not possible in Java to write a swap routine that sw.pdfFORTUNE2505
 

More from FORTUNE2505 (20)

Why would a manager be concerned with bandwidth How is bandwidth me.pdf
Why would a manager be concerned with bandwidth How is bandwidth me.pdfWhy would a manager be concerned with bandwidth How is bandwidth me.pdf
Why would a manager be concerned with bandwidth How is bandwidth me.pdf
 
Where would the Internet be today if the UNIX operating system did n.pdf
Where would the Internet be today if the UNIX operating system did n.pdfWhere would the Internet be today if the UNIX operating system did n.pdf
Where would the Internet be today if the UNIX operating system did n.pdf
 
What do you understand by degrees of Data AbstractionSolution.pdf
What do you understand by degrees of Data AbstractionSolution.pdfWhat do you understand by degrees of Data AbstractionSolution.pdf
What do you understand by degrees of Data AbstractionSolution.pdf
 
validity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdf
validity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdfvalidity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdf
validity. (The Case lulTTtuT 2. Discuss the Economics of Effective Ma.pdf
 
Twitter had their IPO in 2013. Which of the following is not accurate.pdf
Twitter had their IPO in 2013. Which of the following is not accurate.pdfTwitter had their IPO in 2013. Which of the following is not accurate.pdf
Twitter had their IPO in 2013. Which of the following is not accurate.pdf
 
Use C programmingMake sure everything works only upload.pdf
Use C programmingMake sure everything works only upload.pdfUse C programmingMake sure everything works only upload.pdf
Use C programmingMake sure everything works only upload.pdf
 
The Adventures of Huckleberry Finn was published twenty years after .pdf
The Adventures of Huckleberry Finn was published twenty years after .pdfThe Adventures of Huckleberry Finn was published twenty years after .pdf
The Adventures of Huckleberry Finn was published twenty years after .pdf
 
Step 1 You work for Thunderduck Custom Tables Inc. This is the first.pdf
Step 1 You work for Thunderduck Custom Tables Inc. This is the first.pdfStep 1 You work for Thunderduck Custom Tables Inc. This is the first.pdf
Step 1 You work for Thunderduck Custom Tables Inc. This is the first.pdf
 
Researchers argue about whether Oldowan toolmakers were hunters or s.pdf
Researchers argue about whether Oldowan toolmakers were hunters or s.pdfResearchers argue about whether Oldowan toolmakers were hunters or s.pdf
Researchers argue about whether Oldowan toolmakers were hunters or s.pdf
 
In Aristotles Poetics he speaks of epics and tragedies. How do.pdf
In Aristotles Poetics he speaks of epics and tragedies. How do.pdfIn Aristotles Poetics he speaks of epics and tragedies. How do.pdf
In Aristotles Poetics he speaks of epics and tragedies. How do.pdf
 
Name the type of chemical messenger is released from the axon termina.pdf
Name the type of chemical messenger is released from the axon termina.pdfName the type of chemical messenger is released from the axon termina.pdf
Name the type of chemical messenger is released from the axon termina.pdf
 
Marilee Jones, the former dean of admissions of the Massachusetts In.pdf
Marilee Jones, the former dean of admissions of the Massachusetts In.pdfMarilee Jones, the former dean of admissions of the Massachusetts In.pdf
Marilee Jones, the former dean of admissions of the Massachusetts In.pdf
 
Know how the complement of mRNAs in a cell can be assayed (in plants.pdf
Know how the complement of mRNAs in a cell can be assayed (in plants.pdfKnow how the complement of mRNAs in a cell can be assayed (in plants.pdf
Know how the complement of mRNAs in a cell can be assayed (in plants.pdf
 
In Module 5 the you are here slide indicates we are currently in.pdf
In Module 5 the you are here slide indicates we are currently in.pdfIn Module 5 the you are here slide indicates we are currently in.pdf
In Module 5 the you are here slide indicates we are currently in.pdf
 
Identify the role you believe mobile devices have on email investiga.pdf
Identify the role you believe mobile devices have on email investiga.pdfIdentify the role you believe mobile devices have on email investiga.pdf
Identify the role you believe mobile devices have on email investiga.pdf
 
I have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdfI have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdf
 
4. Real gross domestic prodact A. measures the value of fimal goods a.pdf
4. Real gross domestic prodact A. measures the value of fimal goods a.pdf4. Real gross domestic prodact A. measures the value of fimal goods a.pdf
4. Real gross domestic prodact A. measures the value of fimal goods a.pdf
 
Hypothesis What is your hypothesis for the genetic characteristi.pdf
Hypothesis  What is your hypothesis for the genetic characteristi.pdfHypothesis  What is your hypothesis for the genetic characteristi.pdf
Hypothesis What is your hypothesis for the genetic characteristi.pdf
 
How is a process shown in a DFD(data flow diagramSolution Data.pdf
How is a process shown in a DFD(data flow diagramSolution  Data.pdfHow is a process shown in a DFD(data flow diagramSolution  Data.pdf
How is a process shown in a DFD(data flow diagramSolution Data.pdf
 
Hey,Why is it not possible in Java to write a swap routine that sw.pdf
Hey,Why is it not possible in Java to write a swap routine that sw.pdfHey,Why is it not possible in Java to write a swap routine that sw.pdf
Hey,Why is it not possible in Java to write a swap routine that sw.pdf
 

Recently uploaded

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Recently uploaded (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

I need to implement in c++ this non-List member function void print.pdf

  • 1. 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 Solution #ifndef LISTITR_H #define LISTITR_H #include #include "stdafx.h" // This is the content of the .h file, which is where the declarations go class ListNode{ public: ListNode* previous; int value; ListNode* next; ListNode(); }; class ListItr { public: ListNode* current; ListItr(ListNode* theNode); void Insert(int value) const; bool isPastEnd() const; bool isPastBeginning() const; void moveForward() ; void moveBackward() ; int retrieve() const; }; // This is the end of the header guard #endif
  • 2. // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #include #include #include #include "ListItr.h" // TODO: reference additional headers your program requires here #include "stdafx.h" /* for this first you need a class named ListNode */ using namespace std; ListNode::ListNode() { previous=NULL; next=NULL; } 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; }
  • 3. 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 ListItr::Insert(int value) const{ ListNode* theNode; theNode->value=value; while(!isPastEnd()) { moveForward(); }//loop ends when current-> next is null current->next = theNode;//inserts value at the end of the list theNode->previous=current;//defines previous pointer theNode->next=NULL;//defines next pointer } //Startnode is the first node of the list void printList(ListNode* Startnode, bool forward){ // if(forward==true){ // moveForward(); // } // if(forward == false){ // moveBackward(); // } //object of class ListItr ListItr list(Startnode); if(forward==true) {