假设我有一个类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;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我这样做时:
B b;
std::vector<A>::iterator it;
it=std::find (b.get_v().begin(), b.get_v().end(), an item of class A);
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
error: no matching function for call to 'find(std::vector<A>::iterator, std::vector<A>::iterator, A&)
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?谢谢
Ker*_* SB 80
你忘了#include <algorithm>
.