title: C++ - Setting a node to NULL doesn't work
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  struct node{
    int val;
    node* left, *right;
  };
  
  void _delete(node *root)
  {
    root = NULL;
  }
  void change(node *root)
  {
    root-&gt;val = 6;
  }
  int main()
  {
    node * root = new node;
    root-&gt;val = 5;
    change(root);
    _delete(root);
    cout&lt;&lt;root-&gt;val&lt;&lt;endl;
    return 0;
  }
  </code></pre>
  
  <p>The output of the above program is 6. It seems as if the <code>_delete</code> function has no effect on the root node but <code>change</code> function has an effect on the root node. It is almost as if <code>delete</code> treats the argument passed as a local variable but <code>change</code> treats the argument as a global variable. Is there anything that I am missing out or is this normal? If it is normal, please explain.</p>