I have a problem when creating the insert method of the binary search tree in c++ it throws me the following error:
argument of type "void" is incompatible with parameter of type "nodo *"
And my embed code is as follows:
void ingresar_elemento(ABB &arbol, Alumno dato) {
if (arbol == NULL) {
numNodos++;
arbol = new nodo;
arbol->guardaObjeto(dato);
arbol->guardaNodoIzq(NULL);
arbol->guardaNodoDer(NULL);
}
else if (dato.dameNombre() < arbol->dameObjeto().dameNombre().c_str()) {
arbol->guardaNodoIzq(ingresar_elemento(arbol->dameNodoIzq(), dato));
}
else if (dato.dameNombre() > arbol->dameObjeto().dameNombre().c_str()) {
arbol->guardaNodoDer(ingresar_elemento(arbol->dameNodoIzq(), dato));
}
else if (dato.dameNombre() == arbol->dameObjeto().dameNombre().c_str()) {
cout << "El elemento que ingreso ya existe" << endl;
system("pause");
}
return arbol;
}
You are using the instruction
return
in avoid
, to solve this you change itvoid
tonodo*
: