title: Binary Tree implementation C++
body: <p>Binary Tree insertion:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  struct TreeNode {
    int value;
    TreeNode* left;
    TreeNode* right;
  };
  
  struct TreeType {
    TreeNode* root;
  
    void insert(TreeNode* tree, int item);
  
    void insertItem(int value) {
      insert(root, value);
    }
  };
  
  void TreeType::insert(TreeNode* tree, int number) {
    if (tree == NULL) {
      tree = new TreeNode;
      tree-&gt;left = NULL;
      tree-&gt;right = NULL;
      tree-&gt;value = number;
      cout &lt;&lt; "DONE";
    } else if (number &lt; tree-&gt;value) {
      insert(tree-&gt;left, number);
    } else {
      insert(tree-&gt;right, number);
    }
  }
  
  int main() {
    TreeType* MyTree = new TreeType;
    MyTree-&gt;insertItem(8);
  
    return 0;
  }
  </code></pre>
  
  <p>I am currently learning Data structures in C++ and this is the code that make insertion in binary trees.</p>
  
  <p>After it is compiled, everything looks fine, however when i try to execute this program, it crashed. </p>
  
  <p>Can anybody tell me where I am wrong?</p>