L
little.freaky
Hello group,
I have a problem with template classes and inheritance. I've searched
on the internet to find a solution but all the examples look the same
as my code (as far as I can tell) and I can't find my mistake (maybe
there's something wrong with my eyes).
I've two classes:
template< class T >
class ITestTemplateA
{
public:
ITestTemplateA() { };
virtual ~ITestTemplateA() { };
};
template< class T >
class TestTemplateB : public ITestTemplateA< T >
{
public:
TestTemplateB();
virtual ~TestTemplateB();
};
and the implementation of TestTemplateB:
template < class T>
TestTemplateB<T>::TestTemplateB()
{
}
template< class T >
TestTemplateB<T>::~TestTemplateB()
{
}
Now I want to instantiate an object of type TestTemplateB:
TestTemplateB<ITrack>* track = new TestTemplateB<ITrack>();
Where ITrack is another class, but I think that the source-code to that
class isn't important (?). This compiles but the linker shows an error:
error LNK2001: unresolved external symbol "public: __thiscall
TestTemplateB<class ITrack>::TestTemplateB<class ITrack>(void)"
(??0?$TestTemplateB@VITrack@@@@QAE@XZ)
Can somebody tell my what I'm doing wrong?
thanks in advance
Michael Doswald
I have a problem with template classes and inheritance. I've searched
on the internet to find a solution but all the examples look the same
as my code (as far as I can tell) and I can't find my mistake (maybe
there's something wrong with my eyes).
I've two classes:
template< class T >
class ITestTemplateA
{
public:
ITestTemplateA() { };
virtual ~ITestTemplateA() { };
};
template< class T >
class TestTemplateB : public ITestTemplateA< T >
{
public:
TestTemplateB();
virtual ~TestTemplateB();
};
and the implementation of TestTemplateB:
template < class T>
TestTemplateB<T>::TestTemplateB()
{
}
template< class T >
TestTemplateB<T>::~TestTemplateB()
{
}
Now I want to instantiate an object of type TestTemplateB:
TestTemplateB<ITrack>* track = new TestTemplateB<ITrack>();
Where ITrack is another class, but I think that the source-code to that
class isn't important (?). This compiles but the linker shows an error:
error LNK2001: unresolved external symbol "public: __thiscall
TestTemplateB<class ITrack>::TestTemplateB<class ITrack>(void)"
(??0?$TestTemplateB@VITrack@@@@QAE@XZ)
Can somebody tell my what I'm doing wrong?
thanks in advance
Michael Doswald