Proper desctructor for an class containing dynamic array of objects
Mike
externc at aol.com
Thu Jun 13 16:08:52 UTC 2019
Hi,
my name is Mike and I'm new to D (coming from a Javabackground)
and for fun I'm trying to learn D now.
I created a simple class
class Block {
int a, b;
this() {}
}
And now I have a dynamic array of objects of this class in
another class:
class Foo {
Block[] array = new Block[](10);
this() {
for (int i = 0; i < array.length; i++) {
array[i] = new Block();
}
}
}
How would a proper destructor of class Foo look like?
Is it enough to set "array" to null? Or do I have to set every
element of the array to null and then the array, or nothing of
that at all because the garbage collecter collects it, if the
reference to Foo is set to null?
More information about the Digitalmars-d-learn
mailing list