I'm using templates while implementing AVL trees on Ubuntu.
The file will not compile when I write template class AVLTree<std::list<int> >;
, it tells me:
undefined reference to `AVLTree < std::__cxx11::list < std::__cxx11::basic_string < char, std::char_traits < char>, std::allocator < char> >, std::allocator < std::__cxx11::basic_string < char, std::char_traits < char>, std::allocator < char> > > > >::insert(std::__cxx11::basic_string < char, std::char_traits < char>, std::allocator < char> >)'
And I don't get what it doesn't have the reference to.
But it compiles just fine when I write template class AVLTree<std::list<string> >;
I need to let AVLTree
store linked lists that store string values.
Why does one compile and the other doesn't? How to solve my problem?
PS: I've included <list>
, <string>
, and <iostream>
, along with my own header file.
`, `` and `` are, but we don't know what your custom headerfile is.
– Raymond Chen Nov 11 '17 at 03:09