Hello guys i am trying to create a linked list with templates but i am having some trouble.
Header file:
Code:
#include "../std_lib_facilities.h"
#include <iostream>
using namespace std;
template <class T>
class LinkedList{
private:
struct node{
T data;
node* next;
};
node* head;
node* curr;
node* temp;
public:
LinkedList(){
head=NULL;
curr=NULL;
temp=NULL;
}
void AddNode(T addData){
node* n=new node;
n->next=NULL;
n->data=addData;
if(head==NULL){
head=n;
}else{
curr=head;
while(curr->next!=NULL){
curr=curr->next;
}
curr->next=n;
}
}
void DisplayList(){
curr=head;
while (curr!=NULL){
cout<<curr->data;
}
}
};
Source file:
Code:
#include "LinkedList.h"
int main(){
string a;
cin>>a;
LinkedList<string> Chuan;
Chuan.AddNode(a);
}
Error:1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup