title: How to change my function into a constructor?
body: <p>I need to make a parametrized constructor that creates a perfectly balanced binary search tree given a sorted array. I know how to make a function that creates the BST but how can I make the BST from a constructor?
  This is my function: </p>
  
  <pre><code>    node * sortedArrayBST(double * arr, int start, int end)
      {
          int mid = (start + end)/2;
          if (start &gt; end)
          {
              return NULL;
          }
          //because the array will be sorted
          //the root of the tree will contain the item in the middle of the array so everything less than the middle will go in the left subtree
          //and everything greater than the middle will go in the right subtree
  
          node * root = new node(arr[mid]);
          //recursively make left subtree
          root-&gt;left = sortedArrayBST(arr, start, end-1);
          //recursively make left subtree
          root-&gt;right = sortedArrayBST(arr, mid + 1, end);
  
          return root;
      }
  </code></pre>