title: How to use smart pointers in a simple tree implementation
body: <p>This is a node for B+ tree. I wanted to use smart pointers as my program is leaking a lot of memory. How can convert the code by using smart pointers ?</p>
  
  <pre><code>class node
  {
  
  public:
  
      long* key;
      int capacity;
      node** nodes;
      node* parent;
      long* value;
  
      node ( int order ) {
          key = new long[order + 1];
          value = new long[order + 1];
          nodes = new node *[order + 2];
          capacity = 0;
          parent = NULL;
          for ( int i = 0; i &lt;= order + 1; i++ ) {
              this-&gt;nodes[i] = NULL;
          }
      }
      ~node() {
          delete[] key;
          delete[] value;
          for ( int i = 0; i &lt;= order + 1; i++ ) {
              delete nodes[i];
          }
      }
  
  };
  </code></pre>