【发布时间】:2013-01-17 04:29:49
【问题描述】:
我收到了错误:
no matching function for call to ‘findByPosition::findByPosition(std::vector<int>::size_type&, std::vector<int>::size_type&)’
当我将 i 和 k 转换为 int 时,我得到:
no matching function for call to ‘findByPosition::findByPosition(int, int)’
我不知道我的谓词有什么问题。我已经根据需要重载了() 运算符:
struct findByPosition
{
const Node needle;
findByPosition(const Node& sought) : needle(sought) {}
bool operator()(int i,int j) const
{
return ((needle.i == i) && (needle.j == j));
}
};
SparseMatrix& SparseMatrix::operator*=(const SparseMatrix &other)
{
SparseMatrix SparseMatrixResult(_numRow, other._numCol);
vector<Node>::iterator rowMulti, colMulti;
if(_numCol != other._numRow)
{
// error multiplying
}
for(std::vector<int>::size_type i = 0; i != (unsigned int)_numRow; i++) {
for(std::vector<int>::size_type j = 0; j != (unsigned int)_numCol; j++) {
for(std::vector<int>::size_type k = 0; k != (unsigned int)_numCol; k++)
{
rowMulti = find_if(_matrix.begin(), _matrix.end(), findByPosition(i,k));
}
}
}
*this = SparseMatrixResult;
return *this;
}
_matrix 的类型为:
vector<Node> _matrix;
【问题讨论】:
-
如果找到元素,如何使用rowMulti?我只看到几个循环,但没有做任何其他事情?