Doubts with destructor
<p>Suppose I have a class:</p>

<pre><code>class ClassX{
   private:
      int* p;
      int i;
   ....
}
</code></pre>

<p>And somewhere I do:</p>

<pre><code>ClassX x;
.....
//and in a friend function or in a ClassX function
p = (int*) malloc (.....);
</code></pre>

<p>Then when <code>x</code> exit its scope a the destructor is invoked; but it does not free the memory allocated by the <code>malloc</code> right?</p>

<p>And if I redefine it:</p>

<pre><code>ClassX::~ClassX(){ delete [] p; }
</code></pre>

<p>it frees the memory allocated by the <code>malloc</code> but not the memory allocated for the class' fields (i.e. <code>i</code> and <code>p</code>)?</p>

<p>Am I missing something?</p>

<p>Thank you.</p>
