当我在 VS 2017 中编译我的 C++ 程序时,我收到一个编译错误说: binary'==':no operator found which takes a left-hand operation of type std::vector<int, std::allocator_Ty>
(or there is no Acceptable conversion)。这是我第一次使用二维向量,我不确定这是否可能是原因的一部分。我的代码如下。任何人都可以帮助找出为什么会这样吗?
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int>> feeds;
void foo()
{
find(feeds.begin(), feeds.end(), feeds[0][0]);
}
您正在尝试将 int 与向量进行比较。
行feeds.erase(find(feeds.begin(), feeds.end(), feeds[l][k]));
, 有两个向量迭代器(feeds.begin()
和feeds.end()
),但feeds[l][k]
指的是特定的向量位置而不是向量。feeds[l]
指的是向量,应改为使用。
但是,find
当您已经知道要擦除哪个向量时,为什么还需要( feeds[l]
)。我建议你检查你的逻辑并从那里开始。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句