函数模板问题 编译错误
程序代码:
// //实例 template<typename T1, typename T2> T1 findValue (T1 beg, T1 vend, T2 ival) { return beg; } //声明 template<typename T1, typename T2> T1 findValue (T1 beg, T1 vend, T2 ival); //运行 findValue (vec.begin(), vec.end(), 5);
编译错误:
undefined reference to `__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > > findValue<__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int)'|
简化一下就是
undefined reference to `T findValue<T, int>(T, T, int)'|
给我找一下什么情况.. 找不出来
[此贴子已经被作者于2017-12-24 07:53编辑过]