title: Why is there memory leak when base class constructor is being called?
body: <p>I am practicing some inheritance and virtual destructors and i keep getting problem with exception being thrown after running my code, where child class destructor works properly but superclass destructor just wont work properly. </p>
  
  <p>I suppose that i have a few misconceptions about destructors since every time i saw virtual destructors, command 'delete' was used outside of destructor actually, but, if i do that, then, what is the point of creating destructor?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  template &lt;class T&gt;
  class List
  {
  protected:
      T *data;
  
  
  
  public:
      List()
      {
  
          data = new T[5];
          std::cout &lt;&lt; "List constructor!";
      }
  
  
      virtual void putIn()
      {
          for (int i = 0; i &lt; 4; i++)
              std::cin &gt;&gt; data[i];
      }
      virtual void printOut()
      {
          for (int i = 0; i &lt; 5; i++)
              std::cout &lt;&lt; data[i] &lt;&lt; std::endl;
      }
      virtual ~List()
      {
          delete[]data;
          std::cout &lt;&lt; "List destructor!";
      }
  
  
  };
  
  
  template &lt;class T&gt;
  class League : public List&lt;T&gt;
  {
  public:
      League()
      {
  
          data = new T[5];
          std::cout &lt;&lt; "League constructor!";
      }
  
  
      virtual void putIn()
      {
          std::cout &lt;&lt; "Enter your values:\n";
          for (int i = 0; i &lt; 5; i++)
              std::cin &gt;&gt; data[i];
      }
      virtual void printOut()
      {
          std::cout &lt;&lt; "Your values are:\n";
          for (int i = 0; i &lt; 5; i++)
              std::cout &lt;&lt; data[i] &lt;&lt; std::endl;
      }
  
  
     ~League()
      {
          delete[]data;
          std::cout &lt;&lt; "League destructor!";
      }
  
  };
  
  
  
  int main()
  {
      List&lt;char&gt; *p;
      League&lt;char&gt; leag;
  
      p = &amp;leag; 
  
      p -&gt;putIn();
  
  
      getchar();
      getchar();
  
  
  
  
  }
  </code></pre>
  
  <p>Everything works just fine, but when program finishes, it says that exception is thrown it points to the base class destructor. Any help appreciated!</p>