【发布时间】:2016-05-21 23:39:37
【问题描述】:
我正在尝试使用 STL 在 C++ 中实现一个函数,该函数接受一个对象和一个对象向量,如果向量包含对象则返回 true,否则返回 false。下面是函数的实现:
bool belongs(vertex V, std::vector<vertex> &array)
{
std::vector<vertex>::iterator it;
it = find(array.begin(), array.end(), V);
if(it != array.end())
{
return true;
}
else
{
return false;
}
}
但是,我收到此错误:
invalid operands to binary expression ('vertex' and 'const vertex')
if (*__first == __value_)
我能做什么?我对使用面向对象编程的 STL 编程有点陌生,所以期待您的帮助。
【问题讨论】:
标签: oop c++ algorithm data-structures stl