27 lines
599 B
Plaintext
27 lines
599 B
Plaintext
import io:*;
|
|
import mem:*;
|
|
|
|
obj ClassWithConstructor {
|
|
var data: int;
|
|
fun construct(inData: int): *ClassWithConstructor {
|
|
data = inData;
|
|
return this;
|
|
}
|
|
fun printData(): void {
|
|
println(data);
|
|
}
|
|
};
|
|
|
|
fun main(): int {
|
|
var object.construct(4): ClassWithConstructor;
|
|
//ClassWithConstructor object;
|
|
//object.construct(4);
|
|
object.printData();
|
|
var a: int = 8;
|
|
println(a);
|
|
var objPtr: *ClassWithConstructor = new<ClassWithConstructor>()->construct(11);
|
|
objPtr->printData();
|
|
delete<ClassWithConstructor>(objPtr);
|
|
return 0;
|
|
}
|