Reputation: 3
When compiling the code below, I get the following error:
error: no matching function for call to 'diccTrie::iterador::iterador(const diccTrie* const, diccTrie::Nodo* const&)'
class diccTrie{
public:
/* ... */
class iterador{
private:
const diccTrie* diccionario;
const struct Nodo* actual;
friend class diccTrie;
iterador(const diccTrie* d, const Nodo* n): diccionario(d), actual(n){}
};
iterador crearIt() const;
private:
struct Nodo
{
Nodo(const char c) : padre(NULL), hijos(aed2::Lista<Nodo*>::Lista()), clave(c), significado(NULL) {};
~Nodo(){
delete padre;
delete significado;
hijos.~Lista();
}
bool operator==(const Nodo& otro) const{
if(otro.hijos.Longitud() != hijos.Longitud()){
return false;
}
else{
return otro.hijos == hijos && otro.padre == padre && otro.clave == clave && otro.significado == significado;
}
}
Nodo* padre;
aed2::Lista<Nodo*> hijos;
char clave;
const int* significado;
};
Nodo* raiz;
};
The error occurrs in diccTrie::clearIt
which is implemented as
diccTrie::iterador diccTrie::crearIt() const{
return iterador(this, raiz);
}
Where does the error come from?
Upvotes: 0
Views: 1114
Reputation: 3442
In the definition of iterador
, const struct Nodo* actual;
introduced Nodo
in global namespace as the name is not found, so the declaration of the constructor of iterador
is in fact iterador(const diccTrie* d, const ::Nodo* n)
, but not iterador(const diccTrie* d, const diccTrie::Nodo* n)
.
You can add a forward declaration of struct Nodo;
before the definition of iterador
in class diccTrie
. Then in the declaration of iterador
's constructor, diccTrie::Nodo
would be found.
Upvotes: 3