Question: I need 4 swap functions with another list c++ thank you the parameter (&another list) here is the problems 1. Swap the second node of

I need 4 swap functions with another list c++ thank you

the parameter (&another list)

here is the problems

1. Swap the second node of the calling object with the first node of the parameter object.

2. Swap the value of the second node of the calling object with the value of the first node of the parameter object.

3. Swap the second node of the calling object with the last node of the parameter object.

4. Swap the value of the second node of the calling object with the value of the last node of the parameter object.

class Node { public: Node() : data(0), next(nullptr) {} Node(int theData, Node *newNext) : data(theData), next(newNext){} Node* getNext() const { return next; } int getData( ) const { return data; } void setData(int theData) { data = theData; } void setNext(Node *newNext) { next = newNext; } ~Node(){} private: int data; Node *next; // Pointer that points to next node. };

class AnyList { public: AnyList() : first(nullptr), count(0) {}

void print() const;

void clearList(); ~AnyList();

private: Node *first; // Pointer to point to the first node in the list. int count; // Variable to keep track of number of nodes in the list. };

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!