I am receiving this error \"a template declaration cannot appear at block scope.
ID: 3746736 • Letter: I
Question
I am receiving this error "a template declaration cannot appear at block scope." pls help! this is .h file
ecc-auar. Homework 0 doublylinkedlist.h *ebrie Appends a new Node at t.he end of the DoublyT.inkedT.ist 4 Eparam data A pointer to the data to be stored in the new Node *ereturn Nothing 4 Creates a new Node to hold the data and appends the Node at the end of the list. The current Node pointer is set to point to the newly *appended Node template void DoublyT.inkedT,ist.data - data; Node *t.oinserti if(Ifirst) first.ptri first->previous-first-next-firsti if (first->next first) == ptr->next ptr->previous- firsti first->next = first->previous = ptr; elsef Nodc *last first->previous ; pt.r->nextfirst.i ptr->previouslasti last->next - ptr; first.-pevious - pt.r: Get Hclp Exit Write Out Read File Where Is Replace Cut Text tTncut Text. Justify To Spell Cur Pos Go To T.ine Mark Text Copy Text 8:48 PM O Type here to search 9/12/2018Explanation / Answer
If you have any doubts, please give me comment...
Node structure/class must have Template variable.
template<class T>
void DoublyLinkedList<T>::append(T* data){
Node<T> *ptr = new Node;
ptr->data = data;
Node<T> *toinsert;
if(!first){
first = ptr;
first->previous = first->next->first;
}
else{
if(first->next==first){
ptr->next = ptr->previous = first;
first->next = first->previous = ptr;
}
else{
Node<T> *last = first->previous;
ptr->next = first;
ptr->previous = last;
last->next = ptr;
first->previous = ptr;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.