This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problems with g++ templates


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]