Is it worth setting pointers to NULL in a destructor?
<p>Imagine I have a class that allocates memory (forget about smart pointers for now):</p>

<pre><code>class Foo
{
public:
  Foo() : bar(new Bar)
  {
  }

  ~Foo()
  {
    delete bar;
  }

  void doSomething()
  {
    bar-&gt;doSomething();
  }

private:
  Bar* bar;
};
</code></pre>

<p>As well as deleting the objects in the destructor is it also worth setting them to NULL?</p>

<p>I'm assuming that setting the pointer to NULL in the destructor of the example above is a waste of time.</p>
