constructor & destructor

Hello a question about constructor & destructor i’m using in

setup function the following code

array = new Array*[100];

for(int i = 0; i < 100; i++) {
array[i] = new Array();
}

then in the destructor

testApp::~testApp()
{
for (int i = 0; i < 100; i++) {
delete[] array[i];
}
delete[] array;
}

Is this correct?

hi, you don’t need the [] in

  
delete[] array[i];  

as array[i] was created with new and not new[]

but on a side note, what is Array? and why are you creating an array of pointers? There’s nothing wrong with doing that and often it is useful, but I’m curious as to why you need to create an array of pointers and not an array of objects (you don’t want to overcomplicate things unnecessarily if you don’t have to)?

P.S. instead of putting the cleanup code in testApp destructor, you can use testApp::exit() (gets called automatically in testApps’s destructor anyway).