visual c++ - Linker problems in C++ template -


i have function template in .h file , included in main file , used create excel chart. if write template function non-template method, well. when make function function template many unresolved external symbol errors calls within function template methods in excel namespace. in visual studio 2010 way.

as example, if in myfunc.h have

template<class t>  void excelgraph(const std::vector<t>& xdata){ //calls various methods in excel namespace } 

and in main.cpp

 #include"myfunc.h"   int main(){  std::vector<float> xdata(100,1);  excelgraph(xdata);  } 

then code generate linker errors. if myfunc.h looks likes this:

void excelgraph(const std::vector<float>& xdata){ //calls various methods in excel namespace } 

and in main.cpp

 #include"myfunc.h"   int main(){  std::vector<float> xdata(100,1);  excelgraph(xdata);  } 

then code compiles , runs fine.

there many linker errors post, they're of form

1>excel_interface_test.obj : error lnk2019: unresolved external symbol "public: void __thiscall excel::_chart::putname(class _bstr_t)" (?putname@_chart@excel@@qaexv_bstr_t@@@z) referenced in function "void __cdecl excelplotting::excelgraph<float>(class std::vector<float,class std::allocator<float> > const &,class std::vector<float,class std::allocator<float> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??$excelgraph@m@excelplotting@@yaxabv?$vector@mv?$allocator@m@std@@@std@@v12@v?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@2@22@z)


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -