So I wrote an octree struct, as follows:
struct octree{
static const int maxdepth=8;
octree* child[8];
uint32_t rgb;//candidates for the extra 8 bits: alpha, lighting, shape(to reduce size)
uint8_t shape;
~octree(){delete[] child;}
};
The concern that I have is with the destructor…
Will it call the destructors of the children or do I have to do that myself?
What you have declared is an array of 8
octree*values. You cannot delete the array itself.You should instead do this:
If you want to delete them all in one hit, you could define it like this:
The reason being that in an octree you either have no children or 8 children.
And yes: when you delete an
octreeinstance, its destructor will be called.