R
Russ Fink
References: said:On Thu, 14 Oct 1999 16:37:25 -0700 in comp.lang.c++, KSG
I wanted to use a class template so I copied the matrix class verbatim
from the comp.lang.c++ FAQ [13.8]. It compiles fine.
But when I try to link it, it doesn't work.
With currently available C++ compilers, you have to put the entire
template source in the included header so the compiler can generate an
instance matching the template args you call for. Putting the template
in a different file and linking won't do it.
This is a reply to an old post, but in the interest of anyone that has
found this thread by searching through Google (or its equivalents),
this issue has existed for a very long time and is addressed in the
C++ FAQ-LITE maintained by Marshall Cline. Here is a link for all
eternity (or at least until Parashift is bought by Microsoft, its
business units carved up and sold off, and its projects off-shored):
http://www.parashift.com/c++-faq-lite/containers-and-templates.html#faq-34.12
The most simple solution is to put the entire template definition
(class decls, method code) in the header file.
Apologies to those who know this already.