Use below code
if(newNode->getData()->name<currNode->getData()->name)
{
if(currNode->getLeftChild()==NULL)
{
return currNode;
}
compare(newNode,currNode->getLeftChild());
return currNode;
}
else if(newNode->getData()->name>=currNode->getData()->name)
{
if(currNode->getRightChild()==NULL)
{
return currNode;
}
compare(newNode,currNode->getRightChild());
return currNode;
}
else
{
currNode==NULL;
return currNode;
}
You are not returning any value in first and second else part
if u dont want to return anything just use return "";