could not deduce template argument for 'T'是怎么回事,哪位牛人帮下忙啊?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了could not deduce template argument for 'T'是怎么回事,哪位牛人帮下忙啊?相关的知识,希望对你有一定的参考价值。
下面这个程序:
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
template <class T>
bool palindrome(vector<T>::iterator begin,vector<T>::iterator end)
vector<T> u;
vector<T>::iterator uit;
uit=u.begin();
copy(begin,end,uit);
reverse(u.begin(),u.end());
if(equal(begin,end,u.begin()))
return true;
return false;
class palin
private:
int a;
public:
// bool operator==(palin&) const;
void input(int);
;
/*bool palin::operator ==(palin&p) const
if(a-p.a==0)
return true;
return false;
*/
void palin::input(int m)
a=m;
void main()
int num[10]=1,2,3,4,5,5,4,3,2,1,i;
char str[10]="abcdeabcd";
palin Class[10];
for(i=0;i<10;i++)
Class[i].input(i+1);
vector<int> n(num,num+10);
if(palindrome(n.begin(),n.end()))
cout<<"Num is palindrome."<<endl;
else cout<<"Num is not palindrome."<<endl;
vector<char> s(str,str+10);
if(palindrome(s.begin(),s.end()))
cout<<"Str is palindrome."<<endl;
else cout<<"Str is not palindrome."<<endl;
vector<palin> c(Class,Class+10);
if(palindrome(c.begin(),c.end()))
cout<<"Class is palindrome."<<endl;
else cout<<"Class is not palindrome."<<endl;
编译出错:
E:\编程\20章14题\20章14题.cpp(50) : error C2783: 'bool __cdecl palindrome(generic-type-279,generic-type-279)' : could not deduce template argument for 'T'
E:\编程\20章14题\20章14题.cpp(54) : error C2783: 'bool __cdecl palindrome(generic-type-279,generic-type-279)' : could not deduce template argument for 'T'
E:\编程\20章14题\20章14题.cpp(58) : error C2783: 'bool __cdecl palindrome(generic-type-279,generic-type-279)' : could not deduce template argument for 'T'
Error executing cl.exe.
恳请高手帮忙。
palindrome是判断容器的元素是否回文的函数,如容器n与倒置后相等,故它回文,palindrome应返回true
以上是关于could not deduce template argument for 'T'是怎么回事,哪位牛人帮下忙啊?的主要内容,如果未能解决你的问题,请参考以下文章
Could not load the FreeMarker template named 'select'
C++ 编译报错:couldn’t deduce template parameter ‘xxx’(模板参数推导失败)
C++ 编译报错:couldn’t deduce template parameter ‘xxx’(模板参数推导失败)
Weex 添加插件之解决could not find gradle wrapper within android sdk
vue-cli 项目安装失败 tunneling socket could not be established, cause=connect ECONNREFUSED
Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac‘ Could not resolve all