I have a problem in the book (not for homework) that says.
List Reverse
Modify the linked list class you created in the previous programming challenges by
adding a member function named reverse that rearranges the nodes in the list so that
their order is reversed. Demonstrate the function in a simple driver program.
I am way over my head on this one. Can someone suggest how i can start? For instance what kind of loops should i use and such. This is my header file...
#ifndef NUMBERLIST_H
#define NUMBERLIST_H
#include <iostream>
using namespace std;
class NumberList
{
private:
struct ListNode
{
int value;
struct ListNode *next;
};
ListNode *head;
public:
NumberList()
{ head = NULL; }
NumberList(NumberList &);
//~NumberList();
void appendNode(int);
void insertNodeSmallToLarge(int);
void insertNodeLargeToSmall(int);
void deleteNode(int);
int getNodeValue(int);
int getListSize();
void reverseNodes();
void displayList();
};
#endif