So I wanted to make an avl tree in c++.I used a class to make the nodes and a class for the rest of the fuctions ( instert,delete etc).When I want to make more than one trees I decided that i needed to make more roots(one for every tree).The problem is when I declare the new root inside the main.When i declare it outside it seems to work fine. This is the class
class avl_node
{
public:
int data;
avl_node *left;
avl_node *right;
}*root;
and this is the main
int main()
{
avl_node *roott;
int item;
avlTree avl;
avlTree kk;
root=avl.insert(root,item);
roott=kk.insert(roott,item);
kk.display(roott, 1);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire