
Static member variables of template class
Quote:
>Static member variables of non primitive types in template
>classes leads to the linker error (VC+ 5.0):
>TemplateTest.o : fatal error LNK1179: invalid or corrupt file: Comdat
>Example:
>class B {
> B() {}
> ~B() {}
>};
>template<class T1, class T2>
>class T {
> T() {}
> ~T() {}
> static B comp;
>};
>The error occurs if the template is resolved two times
>with the same first argument type but with different
>second type.
>T<B, int> t1;
>T<B, float> t2;
>What's wrong with this code?
I don't have VC5 installed anymore, but where's the definition of the comp
member? Try adding the following after the class T definition:
template<class T1,class T2> B T<T1,T2>::comp;
--
Doug Harrison