> Hello everyone.
>
[quoted text clipped - 9 lines]
> that are not template based are perfectly happy to be infused with
> their body in the cpp. WHat's the matter?
> > The problem may be obvious, though I'm a bit puzzled by the error
> > LNK2028 when attempting to utilize my static library. The all methods
[quoted text clipped - 7 lines]
> > that are not template based are perfectly happy to be infused with
> > their body in the cpp. WHat's the matter?
> Templates aren't compiled until the parameters are known, so the compiler
> needs source code (not just a static library) to make new template
> instances. So either put the template source in your header file, or
> pre-instantiate all the different combinations you might want in the
> library.
Hiah. I've assumed that this is the problem, though one more question.
How to preinstantiate a class along with these particular template
based methods? Would u give me example for the AllocateBuffers method
and, let's say, substitute the int type for ElType?
Cheers,
Peter.
Ben Voigt - 22 Mar 2007 19:55 GMT
> Hiah. I've assumed that this is the problem, though one more question.
> How to preinstantiate a class along with these particular template
> based methods? Would u give me example for the AllocateBuffers method
> and, let's say, substitute the int type for ElType?
http://www.comeaucomputing.com/techtalk/templates/#whylinkerror
I think it would be:
template <> int** AllocateBuffers<int>(const unsigned nRequiredBuffSizeC,
const unsigned nRequiredElSizeC);
> Cheers,
> Peter.
Tamas Demjen - 22 Mar 2007 23:07 GMT
> http://www.comeaucomputing.com/techtalk/templates/#whylinkerror
>
> I think it would be:
>
> template <> int** AllocateBuffers<int>(const unsigned nRequiredBuffSizeC,
> const unsigned nRequiredElSizeC);
Since it's a member function, you need to add "LooseFunctions::":
template int** LooseFunctions::AllocateBuffers<int>(const unsigned
nRequiredBuffSizeC, const unsigned nRequiredElSizeC);
Tom
Tom Widmer [VC++ MVP] - 23 Mar 2007 11:13 GMT
>> http://www.comeaucomputing.com/techtalk/templates/#whylinkerror
>>
[quoted text clipped - 7 lines]
> template int** LooseFunctions::AllocateBuffers<int>(const unsigned
> nRequiredBuffSizeC, const unsigned nRequiredElSizeC);
Just to clarify, that should be in the CPP file along with the
non-template function definitions.
Tom