Witam !
Chciałem w sposób rekurencyjny zaimplementować dodawanie kolejnych elementów do drzewa. Napisałem kod lecz wyskakuje mi breakpoint. Mógłby mi ktoś z tym pomóc, coś poradzić ?
Oto kod:
<iostream>
using namespace std;
struct tree
{
int value;
tree* right;
tree* left;
};
void add(tree*& root)
{
int wartosc;
cout<<"Podaj wartosc\t";
cin>>wartosc;
root->value=wartosc;
cout<<"Czy chcesz dalej dodawac:\n1-TAK\n2-NIE"<<endl;
int x;
cin>>x;
if(x==1)
{
tree* temp=new tree;
temp=root->left;
add(temp);
temp=root->right;
add(temp);
}
}
int main()
{
tree* root=new tree;
add(root);
cout<<endl<<endl;
system("PAUSE");
}