title: simple binary search tree. Segmentation Fault
body: <p>Just a simple BST to print numbers inorder. Couldn't figure out what I did wrong.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class bst {
   private:
    bst* root;
    bst* left;
    bst* right;
    int value;
  
   public:
    bst(const int&amp; numb) : root(NULL), left(NULL), right(NULL) {
      value = numb;
    }
  
    void insert(const int&amp; numb) {
      if (numb &lt; value) {
        if (left == NULL) {
          left = new bst(numb);
          left-&gt;root = left;
        } else { 
          left-&gt;insert(numb);
        }
      } else if (numb &gt; value) {
        if (right == NULL) {
          right = new bst(numb);
          right-&gt;root = right;
        } else {
         left-&gt;insert(numb);  
        }
      } else if (numb == value) {
        cout &lt;&lt; "duplicated value" &lt;&lt; endl;
      }
    }
  
    void inorder() {
      if (left == NULL) cout &lt;&lt; value &lt;&lt; endl;
      else left-&gt;inorder();
      right-&gt;inorder();
    }
  };
  
  
  int main() {
    bst tree(5);
    tree.insert(7);
    tree.insert(1);
    tree.insert(3);
    tree.insert(2);
    tree.insert(9);
    tree.insert(10);
    return 0;
  }
  </code></pre>