2014-12-30 01:22:09 -05:00
|
|
|
import io:*;
|
2014-06-28 08:31:33 -07:00
|
|
|
|
|
|
|
|
typedef DestructorPrint {
|
2015-05-09 06:24:56 -04:00
|
|
|
var myStr: char*;
|
|
|
|
|
fun construct(str: char*): DestructorPrint* {
|
2014-06-28 08:31:33 -07:00
|
|
|
myStr = str;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2015-05-09 06:24:56 -04:00
|
|
|
fun destruct(): void {
|
2014-06-28 08:31:33 -07:00
|
|
|
println(myStr);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef NoDistruction {
|
2015-05-09 06:24:56 -04:00
|
|
|
var a: int;
|
|
|
|
|
fun dummyFunc(): void {}
|
2014-06-28 08:31:33 -07:00
|
|
|
};
|
|
|
|
|
|
2015-05-09 06:24:56 -04:00
|
|
|
fun indirPrint(): void {
|
|
|
|
|
var testObj.construct("Hello Destructors!"): DestructorPrint;
|
|
|
|
|
var dummy: NoDistruction;
|
2014-06-28 08:31:33 -07:00
|
|
|
}
|
|
|
|
|
|
2015-05-09 06:24:56 -04:00
|
|
|
fun main(): int {
|
2014-06-28 08:31:33 -07:00
|
|
|
indirPrint();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|