xxxxxxxxxx
import std.stdio;
class C {
int id;
this(int id) { this.id = id; }
~this() { writeln("C destructor #", id); }
}
struct S {
int id;
this(int id) { this.id = id; }
~this() { writeln("S destructor #", id); }
}
void main()
{
{
C c1 = new C(1);
scope c2 = new C(2);
S s1 = S(1);
S* s2 = new S(2);
scope s3 = new S(3);
writeln("The inner scope is exiting now.");
}
writeln("Main is exiting now.");
}
static ~this() { writeln("The GC will cleanup after this point."); }