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.
Here is the code I have:
#include <iostream>
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 < 10)
{
num[n++] = N;
}
else
{
cout << "limit reached";
}
}
};
int main ()
{
group First;
number_group A;
First.add(A);
getchar();
return 0;
}