Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me get the errors clean out of my code CODE: / / * * * * * * * * * * *
Please help me get the errors clean out of my code CODE:
The Node class
template
class Node
public:
T data;
Node link nullptr ;
;
The linked list base class
template
class LinkedListBase
public:
~LinkedListBase;
T getFifthElement const cerr "Error: You didn't override this base class method yet" endl; T temp; return temp;
void insertNewFifthElementconst T& data cerr "Error: You didn't override this base class method yet" endl;
void deleteFifthElement cerr "Error: You didn't override this base class method yet" endl;
void swapFifthAndSeventhNodes cerr "Error: You didn't override this base class method yet" endl;
T getLast const;
void pushFrontconst T& data;
void pushBackconst T& data;
void popFront;
void popBack;
string getStringFromList;
protected:
Node head nullptr ;
Node tail nullptr ;
unsigned int count;
;
Write your code below here
template
class SinglyLinkedList : public LinkedListBase
public:
TODO, your methods declarations here
T getFifthElement const;
void insertNewFifthElementconst T& value;
void deleteFifthElement;
void swapFifthAndSeventhNodes;
;
TODO, your method definitions here
template
T getFifthElement
if thiscount
throw std::runtimeerrorNot enough elements in the list.";
if thiscount
return data;
;
template
void insertNewFifthElementconst T& value
if thiscount
thisinsertvalue;
else
ewNodedata value;
fourthNode thisfront;
for int i ; i ; i
fourthNode fourthNodenext;
newNodenext fourthNodenext;
fourthNodenext newNode;
thiscount;
;
template
void deleteFifthElement
if thiscount
throw std::runtimeerrorNot enough elements in the list.";
fourthNode thisfront;
for int i ; i ; i
fourthNode fourthNodenext;
fifthNode fourthNodenext;
fourthNodenext fifthNodenext;
if fifthNode thisback
thisback fourthNode;
thiscount;
;
template
void swapFifthAndSeventhNodes
if thiscount
throw std::runtimeerrorNot enough elements in the list.";
fifthNode temp;
seventhNode temp;
temp seventhNode;
temp fifthNode;
;
Write your code above here
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