Answer the question
In order to leave comments, you need to log in
Why, after converting a branch to a binary tree, does it immediately disappear?
There is a binary tree, which is an English-Russian dictionary. In one method, I need to convert a branch to a tree.
struct Elem
{
char eng[15]; // ключ
char rus[15]; // значение
Elem *left, *right, *parent;
};
Tree::Tree(Elem* node)
{
Copy(node, root);
}
void Tree::Copy(const Elem* from, Elem* to)
{
if (from == nullptr)
{
to = nullptr;
return;
}
to = new Elem;
strcpy_s(to->eng, 15, from->eng);
strcpy_s(to->rus, 15, from->rus);
cout << from->eng << '\t' << to->eng << endl;
Copy(from->left, to->left);
Copy(from->right, to->right);
}
Tree obj;
Insert(obj);
Tree obj2(obj.GetRoot());
cout << obj2.GetRoot();
_getch();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question