I have a problem with a function that the professor gave us, he did it but at the time of compiling it in Borland he shows me the error "Can not convert 'int' to 'NodoAvl', being NodoAvl the name of the struct. Function code.
Function:
NodoAvl* InsertarAvl(NodoAvl *raiz, int dato, bool &hc){
NodoAvl *n1=NULL;<br>
if (raiz == NULL){
raiz = new NodoAvl (dato); **Error cannont convert 'int' to 'strcut'**
hc = true;
}else{
if (dato < raiz->Info){
NodoAvl *iz;
iz = InsertarAvl(raiz->Izq, dato, hc);
raiz->Izq=iz;
// regreso por los nodos del camino de búsqueda
if (hc){ // siempre se comprueba si creció en altura // decrementa el FE por aumentar la altura de rama izquierda
switch (raiz->FE){
case 1: // tenía +1 y creció su izquierda
raiz->FE=0;
hc = false; // árbol deja de crecer
break;
case 0: // tenía 0 y creció su izquierda
raiz->FE=-1; //árbol sigue creciendo
break;
case -1: //aplicar rotación a la izquierda
n1 = raiz->Izq;
if (n1->FE == -1)
raiz = RotacionII(raiz, n1);
else
raiz = RotacionID(raiz, n1);
hc = false;
}
}
}else{
if (dato > raiz->Info){
NodoAvl *dr;
dr = InsertarAvl(raiz->Der, dato, hc);
raiz->Der = dr;
// regreso por los nodos del camino de búsqueda
if (hc){ // siempre se comprueba si creció en altura
//incrementa el FE por aumentar la altura de rama izquierda
switch (raiz->FE){
case 1: // aplicar rotación a la derecha
n1 = raiz->Der;
if (n1->FE == 1)
raiz = RotacionDD(raiz, n1);
else
raiz = RotacionDI(raiz,n1);
hc = false;
break;
case 0: // tenía 0 y creció su derecha
raiz->FE = 1; // árbol sigue creciendo
break;
case -1: // tenía -1 y creció su derecha
raiz->FE = 0;
hc = false; // árbol deja de crecer
}
}
}else
throw "No puede haber claves repetidas " ;
}
}
return raiz;
}