Reputation: 999
My compiler complains in a following way:
Matrix.cpp:58: error: no matching function for call to ‘List::miterator::miterator(List::miterator)’
List.h:99: note: candidates are: List::miterator::miterator(List::miterator&)
List.h:98: note: List::miterator::miterator(List::Node*, Dim)
List.h:97: note: List::miterator::miterator(Dim)
I have class List and class Matrix that inherits from List. class miterator is placed within class List. The line 58 says :
miterator i( nula(ROW) );
and is placed inside :
Matrix Matrix::operator*( const Matrix& right ) const
The matrix is sparse and List is a two dimensional ring. method nula returns iterator on a first marginal sentinel in a given dimension. The dimension is defined globally as :
typedef enum { ROW, COL } Dim;
Dim operator!(Dim dim) { return dim == COL ? ROW : COL; }
Node of a list is defined within List and contains the following fields :
private:
unsigned index[2];
T num;
public:
Node *next[2];
I'd appreciate any help, I have no idea what is wrong. Please keep in mind that I'm a beginner C++ programmer. Thanks in advance.
EDIT: This might be helpful too. From the inside of miterator definition :
miterator( Dim dir ) { direction_flag = dir; }
miterator( Node *n, Dim dir ) { node = n; memory = n; direction_flag = dir; }
miterator( miterator &i ) { node = i.node; memory = i.memory; direction_flag = i.direction_flag; }
~miterator() {}
inline bool operator==( const miterator& i) const { return node == i.node; }
inline bool operator!=( const miterator& i) const { return node != i.node; }
inline miterator& operator=( const miterator i ) { node = i.node; memory = i.memory; return *this; }
Upvotes: 0
Views: 167
Reputation: 258648
List::miterator::miterator(List::miterator&)
should be
List::miterator::miterator(List::miterator const&)
A temporary (nula(ROW)
in your case) can't bind to a non-const
reference. Either change the constructor (recommended) or don't use a temporary.
nula n(ROW);
miterator i(n);
Upvotes: 1