C++ Heap destructor when data types are implicitly stored
<p>Quick question,</p>

<p>I'm new to C++ and I'm having difficulty understanding the destructors.</p>

<p>I'll explain; lets say we have the following;</p>

<pre><code>int _a;

a::a(int x) {

    _a = x 
}
</code></pre>

<p>then we have </p>

<pre><code>a* a1 = new a(8);
</code></pre>

<p>I understand that a1's data is created on the heap, and a1 is a pointer, where I'm failing is with the destructor;</p>

<pre><code>a::~a() {

    // confusion here
}
</code></pre>

<p>Since _a is not a pointer since it was created implicitly on the heap thanks to new (correct) we cannot delete it so what do we do? </p>

<p>Does</p>

<pre><code>delete a1;
</code></pre>

<p>call the destructor for a int automatically?</p>