Problems with passing objects in tree structure
TreeNode *children[];


That declares an array of pointers however it also requires that you assign memory to it. I never see you allocate that memory.

If you only expect a small amount of children then you can use that upper bound as a static allocation:

#define MAX_CHILDREN 10

//...
TreeNode *children[MAX_CHILDREN];


Otherwise use a vector instead:

std::vector&lt;TreeNode *&gt; children;