Question: please help me with these functions from C++ ****** PARAMETER: ( Another list) ************** 1. Given a non-empty calling object and a non-empty parameter object,
please help me with these functions from C++
****** PARAMETER: (Another list) **************
1. Given a non-empty calling object and a non-empty parameter object, append (add to the end) one or more elements of the calling object to the end of the parameter object.
2. Given a non-empty calling object and a non-empty parameter object, append (add to the end) one or more elements of the parameter object to the end of the calling object.
3. Swap calling object and parameter object. Think how to implement this one efficiently without any loops.
4. Compare the elements of the calling object and the parameter object and return true if they are the same (make sure to first check if the number of elements is the same, because there is no need to start a loop if the number of elements differs).
---------------------------------------------
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. };
#endif
Thank you so much
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
