Nodes are not trees.
I have seen this confusion several times in StackOverflow in Spanish, and I find it very curious that so many users make that mistake.
In the code you have provided, you are doing a pointer to node alias called arbol
. And that is as wrong as saying that a step is a ladder, sincerely Do you think the same ?:
I need to make a function [...] that replaces tree with tree_new.
Create an object of type arbol
:
class arbol {
ABB *raiz { nullptr };
}
Now you can create a replacement function, which will make a simple exchange of pointers:
class arbol {
ABB *raiz { nullptr };
public:
void reemplazo(arbol &a) {
std::swap(raiz, a.raiz);
}
};