Crashed when i delete a c++ object
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/461203/when-to-use-virtual-destructors">When to use virtual destructors?</a>  </p>
</blockquote>



<hr>

<p>[Second dicuss]
hi,guys! You are all talking about virtual-destructor.
And also i think about the base class`s destructor.
But another test as this:
class A
{
 public:
  A()
  {
  }
  virtual void fun()
  {
  }
 private:
  int mIntA;
};</p>

<p>when class A have a vitual function(not virtual-destrcutor),
it`s ok. Deleting ptrA is OK!</p>

<p>So, i think A just need a vptr to activate the polymorphic. Not class A<code>s 
destructor must be virtual.
Class A</code>s destructor being not virtual just can make resources is not released
correctly.</p>

<hr>

<pre><code>class A
{
 public:
  A()
  {
  }
  /*virtual*/ ~A()
  {
  }
 private:
  int mIntA;
};

class B : public A
{
public:
 B()
 {
  mIntB = 1234;
 }

 virtual ~B()
 {
  int i = 0;
 }

private:
 int mIntB;
};
</code></pre>

<p>I have a class A. And a class B derived form A;
A doesn`t have any virtual function.
so when i do this:</p>

<pre><code>A* ptrA = new B;
delete ptrA;
</code></pre>

<p>it crashes!</p>

<p>but when add a virtual fun to A. it`s ok.
as we know, ptrA is a B object.
but why is it?</p>
