destructors for structs
Submitted by cel..@..il.com
Link to original bug (#622440)
Description
Is there a fundamental reason why structs can have constructors but not destructors? I knows structs are stack based, but a destructor may still be necessary if we manually allocate memory in them.
For example when I try to compile the following test
struct Test
{
int* pointer;
Test()
{
pointer = new int[10];
}
~Test()
{
stdout.printf("Destroying!\n");
delete pointer;
}
}
void main()
{
var p = Test();
}
I get an error message:
error: unexpected declaration in struct
~Test()
^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
Edited by Rico Tzschichholz