I see, thanks for the info. What if i have some other class with an "obj" object and I want to declare an array of "obj *" pointers to objects like so:
Where obj(i,j,k) would be a constructor call for the object. is this too general of an example or can you tell me what I would do with delete in this case?
class obj
{
public:
obj(){}
~obj(){}
};
int main()
{
obj* my_objects[5][6][7];
for (int a = 0; a < 5; ++a)
for (int b = 0; b < 6; ++b)
for (int c = 0; c < 7; ++c)
my_objects[a][b][c] = new obj();
// do stuff
// cleanup:
for (int a = 0; a < 5; ++a)
for (int b = 0; b < 6; ++b)
for (int c = 0; c < 7; ++c)
delete my_objects[a][b][c];
return 0;
}
int * Data[2][2];
for(int a = 0; a < 2; ++a)
{
for(int b = 0; b < 2; ++b)
{
Data[a][b] = newint; // you use the new operator.
}
}
for(int a = 0; a < 2; ++a)
{
for(int b = 0; b < 2; ++b)
{
delete Data[a][b]; // so you must use the delete operator.
}
}
for(int a = 0; a < 2; ++a)
{
for(int b = 0; b < 2; ++b)
{
Data[a][b] = newint[8]; // you use the new[] operator.
}
}
for(int a = 0; a < 2; ++a)
{
for(int b = 0; b < 2; ++b)
{
delete[] Data[a][b]; // so you must use the delete[] operator.
}
}