title: Deleting a Template Type
body: <p>I have a generic class that looks something like this:</p>
  
  <pre><code>template &lt;class T&gt;
  class Example
  {
    private:
      T data;
    public:
      Example(): data(T())
      Example(T typeData): data(typeData) 
      ~Example()
  
      // ...
  };
  </code></pre>
  
  <p>I'm a bit confused about how to implement a deconstructor for something like this. Specifically, since <code>T</code> is of any type, it could be memory allocated on the stack (which is always the case for <code>Example</code>'s created via the no-argument constructor) or on the heap.  </p>
  
  <p>For instance, if the client makes the type for <code>T</code> an <code>int*</code> and provides a pointer to dynamic memory, how do I know to call <code>delete</code> on <code>data</code> as opposed to if the client set the type to <code>int</code>?</p>