G
Good Guy
I've got following class and template function:
template <size_t num>
class String{
public:
char charArray[num];
};
template <size_t num,typename T>
void getString(String<num> & string,T number){
cout <<string.charArray<<' '<<number<<'\n';
}
then I tried to do an explicit instantiation as following to export
that instantiation to a DLL but found out at last that it didn't get
instantiated at all since I got a linker error of unresolved external
symbol by linker at the place I was about to import and use that
function (exact linker error:"**unresolved external symbol
"__declspec(dllimport)
void __cdecl getString<5>(class String<5> &,unsigned char) (__imp_??
$getString@$04@@YAXAAV?$String@$04@@E@Z)**") because "num" was not
specified at the point I was intending to instantiate; at the first
place I was thinking that maybe because String<num> & string would be
implemented as a pointer the following syntax would've been an
instantiation but seems I was wrong.
template<size_t num>
__declspec(dllexport) void getString(String<num> & string,unsigned
char number);
Now how do you suggest I should do the instantiation because I'm not
certainly going to do it for every single integer number found on
earth!!!.
template <size_t num>
class String{
public:
char charArray[num];
};
template <size_t num,typename T>
void getString(String<num> & string,T number){
cout <<string.charArray<<' '<<number<<'\n';
}
then I tried to do an explicit instantiation as following to export
that instantiation to a DLL but found out at last that it didn't get
instantiated at all since I got a linker error of unresolved external
symbol by linker at the place I was about to import and use that
function (exact linker error:"**unresolved external symbol
"__declspec(dllimport)
void __cdecl getString<5>(class String<5> &,unsigned char) (__imp_??
$getString@$04@@YAXAAV?$String@$04@@E@Z)**") because "num" was not
specified at the point I was intending to instantiate; at the first
place I was thinking that maybe because String<num> & string would be
implemented as a pointer the following syntax would've been an
instantiation but seems I was wrong.
template<size_t num>
__declspec(dllexport) void getString(String<num> & string,unsigned
char number);
Now how do you suggest I should do the instantiation because I'm not
certainly going to do it for every single integer number found on
earth!!!.