29 lines
471 B
Plaintext
29 lines
471 B
Plaintext
import io:*;
|
|
|
|
typedef DestructorPrint {
|
|
var myStr: char*;
|
|
fun construct(str: char*): DestructorPrint* {
|
|
myStr = str;
|
|
return this;
|
|
}
|
|
fun destruct(): void {
|
|
println(myStr);
|
|
}
|
|
};
|
|
|
|
typedef NoDistruction {
|
|
var a: int;
|
|
fun dummyFunc(): void {}
|
|
};
|
|
|
|
fun indirPrint(): void {
|
|
var testObj.construct("Hello Destructors!"): DestructorPrint;
|
|
var dummy: NoDistruction;
|
|
}
|
|
|
|
fun main(): int {
|
|
indirPrint();
|
|
return 0;
|
|
}
|
|
|