C++ Templates in library; how to link?
Posted on 1997-12-08
I have in a static library C++ class template. In an application I am trying to link with that library, I am getting unresolved errors with a particular instance of this template. I figured it was becuase this template was not being instantiated in the library and so it couldn't find the proper code in the library to link with.
I checked the online help of MSVC++5.0 and found that you need to 'explicitly instantiate' the template to work. So, I tried it. And what I have does not work.
I have 2 class templates, and made a .cpp file to instantiate both of them to the relevant types, and included whats shown below.
I get warnings of : no suitable definition provided for explicit template instantiation request for each member function and constructor/destructor in the templates file.
And I get unresolved external symbol errors as such:
CuList<class CuChoice>::CuList<class CuChoice>(void)(??0?$CuList@VCuChoice@@@@QAE@XZ)
How should I work this out, and what possibly am I doing wrong with the instantiation? I know its a moutful, but I hope someone can help.
Thanks a lot.