std :: find'错误无匹配函数' [英] std::find 'error no matching function'
本文介绍了std :: find'错误无匹配函数'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个A类和一个B类,如下所示:
A类
{
private:
int a;
public:
bool operator ==(const A&)const;
//其他方法(...)
}
B类
{
private:
std :: vector< A> v;
public:
std :: vector< A> & get_v(){return v;};
const std :: vector< A& get_v()const;
}
现在当我这样做:
B b;
std :: vector< A> :: iterator it;
it = std :: find(b.get_v()。begin(),b.get_v()。end(),A类的一个项)。
我获得的错误是
错误:没有与'find(std :: vector< A> :: iterator,std :: vector< A> :: iterator,A&)调用匹配的函数
我错过了什么?感谢
解决方案
您忘记了 #include< algorithm>
/ p>
Say that I have a class A and a class B that look like that:
Class A
{
private:
int a;
public :
bool operator==(const A &) const;
//other methods(...)
}
Class B
{
private:
std::vector<A> v;
public:
std::vector<A> &get_v() {return v;};
const std::vector<A>& get_v() const;
}
Now when I do that:
B b;
std::vector<A>::iterator it;
it=std::find (b.get_v().begin(), b.get_v().end(), an item of class A);
The error I get is
error: no matching function for call to 'find(std::vector<A>::iterator, std::vector<A>::iterator, A&)
Am I missing something ? Thanks
解决方案
You forgot to #include <algorithm>
.
这篇关于std :: find'错误无匹配函数'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文