This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: problems with g++ templates
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: bernhard_rueckerl at freenet dot de, gcc-help at gcc dot gnu dot org
- Date: Sun, 31 Oct 2004 11:55:41 -0600
- Subject: Re: problems with g++ templates
- References: <4183B592.2040608@freenet.de>
Hi Bernhard,
The problem is you have forgotten to include the template functions in your
testmain.cpp (or alternatively, in your testt.h).
#include "testt.h"
#include "testt.cpp"
#include <iostream>
main()
{
TestT<double> w;
w.setvalue( 2.0 );
cout << w.getvalue( );
}
It's rather unconventional to put the template methods in a .cpp
file. Usually they are put in the header file.
I have seen one convention that put template methods, template functions
and inline functions in a .inl file, at one company I worked at.
HTH,
--Eljay