c++algorithmheaderfind

std::find 'error no matching function'


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


Solution

  • You forgot to #include <algorithm>.