   C++ templates
  hi, I am getting an error message:error LNK2019: unresolved external symbol "public: void __thiscall OccTree<int>::Sink(class AxisAlignedBoundingBox &,int &)const " (?Sink@?$OccTree@H@@QBEXAAVAxisAlignedBoundingBox@@AAH@Z) referenced in function _mainI am guessing it has something to do with my function definitions being in a cpp file.In the cpp file i have writtentemplate<class Type>void OccTree<Type>::Sink(AxisAlignedBoundingBox& box, Type& object)const{template<class Type>OccTree<Type>::OccTree(AxisAlignedBoundingBox box, int levels, OccTree* parent){respectivly.Can anyone cast any light on this problem?Why am i getting an error at linktime instead of compiletime?   
Quote:Original post by Net-NinjaI am guessing it has something to do with my function definitions being in a cpp file.That's it. Take a look at this and this.   ;  [edit] mmm Metsan was just a little bit faster with the same answer :) [/edit]This FAQ covers the question what causes your problem and (probably more important) how you can avoid it: the FAQ;  Thanks, I was guessing it was that. Just wasn't sure.For those who are cruizing by I can say that since the templates are just patterns the compiler just compiles the cpp file that you have written without any patterns since it does not se any instancing of them. This is because the compiler is creating the specific classes at compile time (if the classes were generated at runtime this problem wouldn't exist)To fix this you can either insert a line in the cpp for the type that you want to create a pattern for or you can move all the implementation to the .h file.If you move all your implementation to the .h file your code might get bloated due to the compiler compiling each cpp file separately and then linking them together. Since all the implementation is in the header you get multiple instances of the same thing that may or may not be merged at the linking stage.Thanks alot btw.   