LNK is for linking error
Where is your void insert(T& item); implementation and where is the decleration?
If they are in 2 different files you have to include the second file in the first file after the function is declared. You don't have to include the *.h file in a *.tpp file if only *.tpp functions are in the .tpp file
so you should have something like this:
insert
header.h
1 2 3
template<class T>
void insert(T &item);
#include "template.tpp" // after decleration
template.tpp
1 2
template<class T>
void insert(T &item) {}
Also, your print function just prints the data of the head.
And a reference cannot be 0
That thing is causing the problem.
Where is the implementation?
furthermore, int main() is not a template function ... so you should not declare it like that.
int main has 2 commonly used declerations, use one of them please. int main(int argc, char** argv) { ... }int main() { ... }
and why is there a T in your call: insert(T number);
I didnt copy and paste this code. I had someone help me with it. Took me about 4 days and counting to understand it. I still have to do the delete function and search function so I dont want to hear anymore accusations
Anyways I fixed the minor errors such as the comparisons and the brackets and added one more line. The only problem Im having now is not getting the first the number in the list.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void print(){
Node<T>* current = head;
if(head == NULL){
return;
};
current = current->next;
while(current != head){
cout<<current->data<<endl;
current = current->next;
};
}