What's wrong with this assignment?

Hello again.

Here's a procedure that I can't run. The exe-file just quits here for unknown reason:

btree make_tree (btree a, btree b, char c)
{
btree p;
(p.root)->d=c;
(p.root)->ls=a.root;
(p.root)->rs=b.root;
return p;
}

btree is a class representing binary trees, its only attribute is node *root, where node is a single element of the object (content +2 pointers to other nodes). The procedure in question is supposed to construct a binary tree with the given root element (char c), left branch (btree a) and right branch (btree b).

Can anyone help me understand why the compiler doesn't accept this?

Thanks in advance!
The exe-file just quits here for unknown reason:

Use the debugger to find out what that "unknown reason" is.

Can anyone help me understand why the compiler doesn't accept this?

If you got an executable file, then the compiler apparently accepted it...

Exactly what is p.root pointing to? And what does the copy constructor for btree look like?
Last edited on
Thank you, I'll try it.

p.root is pointing to the top node of the binary tree p (defined by typedef struct as containing a char element and two pointers to branch elements)
The debugger informed me of a segmentation fault. OK, if I don't find the solution to this problem, I'll ask here again. :) Thanks!
Topic archived. No new replies allowed.