Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ LINKEDLIST.H Create a template class (LinkedList.h) that declares a singly-linked list. This template class should be able to create a linked list of any
c++
LINKEDLIST.H Create a template class (LinkedList.h) that declares a singly-linked list. This template class should be able to create a linked list of any type of object. LinkedList class should have the following attributes: A structure (struct) ADT named ListNode, which defines a node with a value & a pointer to the next ListNode A pointer to a ListNode named head A pointer to a ListNode named tail An integer named numNodes LinkedList class should have the following member functions Constructor- should initialize head &tail to point to nothing and initialize numNodes to zero Destructor-like a "RemoveAll" function- should deallocate memory for all existing nodes getLength - should return the number of nodes in the list getNodeValue - this function accepts a position (integer) as a parameter and then returns the value (object) inside the node at that position appendNode-this function accepts a value (object) as a parameter. It creates a new node at the end of the list with the sent object inside of it and increments the number of nodes. This function does not return anything. deleteNode this function accepts a position (integer) as a parameter, which indicates the position of the node to be deleted. It updates the links of the nodes on either side of this node to be deleted. Then it deletes the node. Then, it decrements the number of nodesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started