[solved]-C Linked List 2 Parts Problem 1please Complete Implementation Destructor 2 Please Write Im Q39051730
C++ linked list there is 2 parts to this problem
1.Please complete the implementation of the destructor.
2. Please write an implementation of the addToList memberfunction.
————————
Problem #1: Below is a definition of a LinkedList class and atest main program: #include <iostream> using namespace std;class LinkedList { public: LinkedList(): head(nullptr) { }~LinkedList(); void addToList(int value); // add to the end of thelinked list void reverse(); // Reverse the linked list voidoutput(); private: struct Node { int num; Node *next; }; Node*head; }; void LinkedList::output() { Node *ptr = head; cout<< “The elements in the list are: “; while(ptr!=nullptr) {cout << ptr->num << ” “; ptr = ptr->next; } cout<< endl; } int main() { LinkedList list; for(inti=1;i<=10;i++) list.addToList(i); list.output(); list.reverse();list.output(); }
Expert Answer
Answer to C++ linked list there is 2 parts to this problem 1.Please complete the implementation of the destructor. 2. Please write… . . .
OR