title: C++ array of pointers to objects deletion, "Debug assertion failure!"
body: <p>I have a container class which contains a array of pointers to objects. Each of those objects hold another array of pointers to int. However when trying to delete the array of pointers to int, the program crashes giving the "Debug assertion failed!" error.</p>
  
  <p>Here is the code I have:</p>
  
  <pre><code>#include &lt;iostream&gt;  
  using namespace std;
  
  class number_group
  {
  private:
      int *integers;
  public:
      number_group()
      {
          integers = new int [10];
      }
      ~number_group()
      { 
          delete [] integers; 
      }
  };
  
  class group
  {
  private:
      number_group *num;
      int n;
  public:
      group()
      {
          n = 0;
          num = new number_group [10];
      }
      ~group()
      {
          delete [] num;
      }
      void add(number_group N)
      {
          if (n + 1 &lt; 10)
          {
              num[n++] = N;
          }
          else
          {
              cout &lt;&lt; "limit reached";
          }
      }
  };
  
  int main ()
  {
      group First;
      number_group A;
      First.add(A);
  
      getchar();
      return 0;
  }
  </code></pre>