Question
Hi, I'm doing this code project and I need help with my code. I am getting this error and I don't know how to fix
Hi, I'm doing this code project and I need help with my code. I am getting this error and I don't know how to fix it.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
INSTRUCTIONS
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-MAIN.CPP-
-LEAKER.H-
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MY CODE AND THE ERROR I'M GETTING
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#ifndef LINKEDLIST_H #define LINKEDLIST_H
#include
template
public: // This section describes the methods that are accessible for the LinkedList // class LinkedList(); void AddTail(T data); void AddHead(T data); void PrintForward(); Node *Find(T searchData); void InsertBefore(Node *, T data); void InsertAfter(Node *, T data); void InsertAt(T data, int position); int NodeCount() const; ~LinkedList();
private: Node *head; Node *tail; int totalNodes; };
template
template
template
template
// connecting links to the newNode currentNode->next = newNode;
// checking if the nextNode is not null // if not null then set the prev of the nextNode to the newNode if (nextNode != nullptr) { nextNode->prev = newNode; }
// connecting the newNode links newNode->prev = currentNode; newNode->next = nextNode;
// checking if the newNode is the last node of not if (newNode->next == nullptr) { // if the newNode is the lastNode, then set tail to newNode tail = newNode; }
totalNodes++; }
template
currentNode->prev = newNode;
if (prevNode != nullptr) { prevNode->next = newNode; }
// connecting the newNode links newNode->next = currentNode; newNode->prev = prevNode;
// if the newNode is the first node, then set it to head if (newNode->prev == nullptr) { head = newNode; }
totalNodes++; }
template
template
template
template
template
#endif//LINKEDLIST_H
-ERROR-
For this part you will implement functionality to insert elements into the linked list, one of the primary advantages of this data structure. (This can be achieved with arrays as well, but it is much faster with a linked list). You will implement the following: - InsertBefore0 - InsertAfter0 - InsertAt 0 In addition, you will implement the equality operator, to test if two lists are equal to one another. - operator== File is marked as read only Current file: main.cpp - () 6970717273747576data.InsertAt("lists",5);data.InsertAt("insert",10);data.InsertAt("nodes",11);data.InsertAt("list.",15);data.PrintForward();cout&, const allocator <_t>& ) /usr/include/c++/9/bits/allocator.h:167:5: note: template argument dec main. cpp:30:13: note: 'LinkedList' is not derived from 'const sto 30 if (a==b) Compilation failed In file included from/usr/include/c++/9/string:55, from /usr/include/c++/9/bits/locale_classes.h: 40 , from /usr/include/c++/9/bits/ios_base.h: 41 , from /usr/include/c++/9/ios: 42 , from /usr/include/c++/9/ostream: 38 , from /usr/include/c++/9/iostream: 39, from main. cpp:2: /usr/include/c++/9/bits/basic_string.h: 6144:5: note: candidate: 'templat 6144 I operator==(const basic_strings _ 1 _ /usr/include/c++/9/bits/basic_string.h: 6144:5: note: template argument main. cpp:30:13: note: 'LinkedList> ' is not derived from 'const stc 30 I if (a==b )
Step 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