So I did already manage to solve my problem but I have trouble understanding what exactly was the problem. My code before was:
BinaryTree removePrivate(int x, BinaryTree *node)
{
if ((*node).m_key < x)
*(*node).m_right = removePrivate(x, (*node).m_right);
else if ((*node).m_key > x)
*(*node).m_left = removePrivate(x, (*node).m_left);
else
node= NULL ;
return *node;
}
It compiles just fine but things go to hell when it gets called. Access violation at return *node;
I have changed it to:
[*]= * has been added, [ ]= * has been removed
BinaryTree [*]removePrivate(int x, BinaryTree *node)
{
if ((*node).m_key < x)
[ ](*node).m_right = removePrivate(x, (*node).m_right);
else if ((*node).m_key > x)
[ ](*node).m_left = removePrivate(x, (*node).m_left);
else
node= NULL ;
return [ ]node;
}
Now everything works just fine but I am really not 100% sure why this is better.