std::查找"错误无匹配函数"

std::find 'error no matching function'

本文关键字:函数 无匹配 错误 std 查找      更新时间:2023-10-16

说我有一个看起来像这样的A类A和一个B类:

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;
}

现在这样做时:

B b;
std::vector<A>::iterator it;
it=std::find (b.get_v().begin(), b.get_v().end(), an item of class A);

我得到的错误是

error: no matching function for call to 'find(std::vector<A>::iterator, std::vector<A>::iterator, A&)

我想念什么吗?谢谢

您忘记了#include <algorithm>

我认为您忘记了包括标题<algorithm>

您忘记了包含此标头文件

#include<vector>