Link error:
Error LNK2019 unresolved external symbol "public: __cdecl LinkedList::LinkedList(void)" (??0?$LinkedList@H@@QEAA@XZ) int function main
Also, i can't use LinkedLink declaration in other classes, for example:
template <class T>
class foo{
LinkedList<T> example;
}
this doesn't work
#include <Windows.h>
#include "LinkedList.h"
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
LinkedList<int> cringe; //doesn't compiling
LinkedList<int> wtf(); //compiling
}
LinkedList.h
#pragma once
#include "Node.h"
template <class T>
class LinkedList {
int listSize;
Node<T>* start;
Node<T>* end;
public:
LinkedList();
~LinkedList();
T& operator[](int index);
int size();
Node<T>* get(int index);
void add(T value, int index);
void push(T value);
void erase(int index);
void pop();
void swap(Node<T>* n1, Node<T>* n2);
void print();
};
LinkedList.cpp (cut)
#include "LinkedList.h"
#include <iostream>
using namespace std;
template <class T>
LinkedList<T>::LinkedList() {
start = NULL;
end = NULL;
size = 0;
}
template <class T>
LinkedList<T>::~LinkedList() {
Node<T>* deletePtr = start;
while (deletePtr && deletePtr->next)
{
deletePtr = deletePtr->next;
delete deletePtr->prev;
}
delete deletePtr;
}