I try to use a template in my lib, but a have an error. (I have already set the entire template in header)
in the exe : main.cpp
#include "../lib/Lib.h"
class Test
{
public:
Test();
void test(){}
};
int main(int argc, char *argv[])
{
Lib<Test>* test = new Lib<Test>();
test->execute();
return 0;
}
In dynamic lib : lib.h :
template<class T>
class __declspec(dllexport) Sub : public T
{
public:
Sub();
virtual ~Sub();
};
template<class T>
class __declspec(dllexport) Lib : private Sub<T>
{
public:
Lib();
void execute();
private:
~Lib();
};
template<class T>
Lib<T>::Lib(){};
template<class T>
Lib<T>::~Lib(){};
template<class T>
void Lib<T>::execute()
{
this->test();
}
that won't compile, why ? (undefined reference)
That seem to be related to virtual.
thanks for the help !