0

I have a NewTree class that's been defined in NewTree.h. When I make a new instance of NewTree in my main method, it throws an LNK 2019 error.

NewTree.h:

template <class T>
class NewTree
{
public:

treeNode<T> *current;
treeNode<T> *root;

NewTree();
~NewTree();
bool insert(T *data, treeNode<T> *parent);
treeNode<T> search(T *target);
};

Line to make new instance of NewTree:

NewTree<xml_node<>> *tree = new NewTree<xml_node<>>();

Why is Visual Studio giving me an LNK error?

Full Error:

main.obj : error LNK2019: unresolved external symbol "public: __thiscall NewTree<class rapidxml::xml_node<char> >::NewTree<class rapidxml::xml_node<char> >(void)" (??0?$NewTree@V?$xml_node@D@rapidxml@@@@QAE@XZ) referenced in function _main
guerda
  • 23,388
  • 27
  • 97
  • 146
Alex Alex
  • 101
  • 1
  • 1
  • 8

1 Answers1

1

Your template class has to be implemented in the header file. I think this is the reason of the problem. This is the only thing I can conclude from the code you have provided.

Community
  • 1
  • 1
nogard
  • 9,432
  • 6
  • 33
  • 53