Consider a double-linked linked list implementation with the following node: struct Node {int data; Node *prev; Node *next;} Write a copyList method that is not a member of any class. The method should take a head pointer and return another pointer. Do not modify the input. Solution struct Node { Node *prev; // previous node Node *next; // next node int data; // stored value }; #include #include \"List.h\" // std: #include using namespace std; typedef DataList ; // std: typedef list Data; int main() { Data k; // back stuff k.push_back(5); k.push_back(6); cout << k.back() << endl; k.pop_back(); // front stuff k.push_front(4); k.push_front(3); cout << k.front() << endl; k.pop_front(); // forward iterator Data::iterator pos; for (pos = k.begin(); pos != k.end(); ++pos) cout << *pos << endl; // output and delete list while (!k.empty()) { cout << k.front() << endl; k.pop_front(); } k.push_front(5); k.push_front(6); // remove and erase k.remove(5); pos = k.begin(); k.erase(pos); k.push_front(5); k.push_front(6); // copy constructor Data l = k; // assignment operator Data m; m = k; return 0; } // List.h struct Node; classIterator List; class List { public: typedef ListIterator iterator; // constructor List(); // destructor virtual ~List(); // copy constructor List(const List& k); // assignment operator List& operator=(const List& k); // insert value in front of list void push_front(double data); // insert value in back of list void push_back(double data); // delete value from front of list void pop_front(); // delete value from back of list void pop_back(); // return value on front of list double front() const; // return value on back of list double back() const; // delete value specified by iterator void erase(const iterator& i); // delete all nodes with specified value void remove(double data); // return true if list is empty bool empty() const; // return reference to first element in list iterator begin() const; // return reference to one past last element in list iterator end() const; private: Node *head; // head of list }; class ListIterator { public: // default constructor ListIterator() { i = 0; } // construct iterator for given pointer (used for begin/end) ListIterator(Node *p) { i = p; } // convert iterator to Node* operator Node*() const { return i; } // test two iterators for not equal bool operator!=(const ListIterator& k) const { return i != k.i; } // preincrement operator ListIterator& operator++() { i = i->next; return *this; } // return value associated with iterator double& operator*() const { return i->data; } private: Node *i; // current value of iterator }; list.cpp // delete list static void deleteList(Node *head) { Node *p = head->next; while (p != head) { Node *next = p->next; delete p; p = next; } delete head; } // copy list static void copyList(const Node *from, Node *&to) { // create dummy header to = new Node; to->next = to->prev = to; // copy nodes for (Node *p = from->next; p != from; p = p->next) { Node *t = new Node; t.