I'm trying to define a variable type at runtime based on user input, so what I did was created an abstract base class Variable and derived a templated class from it.
This way I can get the input, determine what type to use, and then do something likeCode:class Variable { public: virtual ~Variable() = 0; }; template<class T> class Data : public Variable { public: Data(); virtual ~Data(); protected: T value; };
and then add all the variables to a map<string,Variable*>. My problem is that when I try to compile the linker gives me this error:Code:Variable* var; var = new Data<int>;
My constructor for Data looks like thisError LNK2019: unresolved external symbol "public: _thiscall Data<int>:ata<int>(void)" (??0?Data@H@@QAE@XZ) referenced in function "protected: void _thiscall Console::def(void)" (?def@Console@@IAEXXZ)
Why isn't the linker able to use my constructor? Is polymorphism even possible with a derived templated class?Code:template<class T> Data<T>::Data() { }