ALL,
In my header file I have:
template<class T> __declspec(dllexport) MyClass : public MyBaseClass
{
public:
template <class T>MyClass(T obj);
~MyClass();
};
In my .cpp file I have:
template<class T> __declspec(dllexport) MyClass::MyClass( T obj ) : MyBaseClass()
{
// body of the constructor
}
MyClass::~MyClass()
{
}
This code errors out on MSVC 2017. MyBaseClass is not a template class.
So I have 2 questions:
- It shouldn't be necessary to templatize every function in the template class. But removing
template<class T>
from the constructor in both .h and .cpp generate an error. - What is the best way to fix an error? Should the base class be a template class as well?
Aucun commentaire:
Enregistrer un commentaire