import std.stdio;
extern(C++) class C {
bool onStack;
this(bool onStack) {
this.onStack = onStack;
}
~this() {
writeln("Destroying ", onStack? "stack" : "heap", " C instance.");
}
}
extern(D) class D {
bool onStack;
this(bool onStack) {
this.onStack = onStack;
}
~this() {
writeln("Destroying ", onStack? "stack" : "heap", " D instance.");
}
}
void main() {
scope stackC = new C(true);
auto heapC = new C(false);
scope stackD = new D(true);
auto heapD = new D(false);
}
已搞定
.