I am to make a rev op on linked node but somehow i couldnt get to work. I got an error I am kinda stuck right now. The error is in gray
Somehow and somewhere doesnt show the reverse link. Can someone show how to do the search node like? I kiddan stuck at that. Can someone help me out thx
// Specification file for the NumberList class
#ifndef NUMBERLIST_H
#define NUMBERLIST_H
class NumberList
{
private:
// Declare a structure for the list
struct ListNode
{
double value; // The value in this node
struct ListNode *next; // To point to the next node
};
ListNode *head; // List head pointer
public:
// Constructor
NumberList()
{ head = NULL; }
// Destructor
~NumberList();
// Linked list operations
void appendNode(double);
void insertNode(double);
void reverseNode(double); // added the new node
void searchNode (double); // added the new node
void deleteNode(double);
void displayList() const;
};
#endif
void NumberList::reverseNode(double num)
{
struct ListNode* head_ref = NULL;
struct ListNode* first;
struct ListNode* rest;
/* empty list */
if (head_ref == NULL)
return;
first = head_ref;
rest = first->next;
/* List has only one node */
if (rest == NULL)
return;
/* reverse the rest list and put the first element at the end */
reverseNode(*rest); // <----- Got an ERROR here
first->next->next = first;
first->next = NULL;
/* fix the head pointer */
*head_ref = *rest;
}