-
template problem
Hi
Here is my problem:
Code:
class A
{
public:
// Constructor and so on....
template <typename T>
int func(T* const& var);
//....
// in the .cpp:
template <typename T>
int A::func(T* const& var) { var->DoSmth(); return 1; }
I included the header into an other classes cpp like:
Code:
//class B .cpp
void B::somefunc()
{
A a;
CDoSmthClass *ds = new CDoSmthClass();
// now I want to call class A's func
a.func(ds);
// The linker fails at this point saying "... unresolved external... public: int __thiscall A::func.......
When I use the func method eg. in class A's constuctor with the CDoSmthClass it compiles without link error!!???!?
-
Re: template problem
include implementation of a::func in header
-
Re: template problem
There are many, many threads on this issue here .. try searching them here in this forum. You will find what needs to be done. In the meantime look at this FAQ - Why do I get unresolved externals with my template code?. Hope this helps. Regards.