2014-12-30 01:22:09 -05:00
|
|
|
import io:*;
|
|
|
|
|
import mem:*;
|
2014-06-26 01:45:44 -07:00
|
|
|
|
2015-05-16 12:05:23 -04:00
|
|
|
obj ClassWithConstructor {
|
2015-05-09 06:24:56 -04:00
|
|
|
var data: int;
|
|
|
|
|
fun construct(inData: int): ClassWithConstructor* {
|
2014-06-26 01:45:44 -07:00
|
|
|
data = inData;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2015-05-09 06:24:56 -04:00
|
|
|
fun printData(): void {
|
2014-06-26 01:45:44 -07:00
|
|
|
println(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-09 06:24:56 -04:00
|
|
|
fun main(): int {
|
|
|
|
|
var object.construct(4): ClassWithConstructor;
|
2014-06-26 01:45:44 -07:00
|
|
|
//ClassWithConstructor object;
|
|
|
|
|
//object.construct(4);
|
|
|
|
|
object.printData();
|
2015-05-09 06:24:56 -04:00
|
|
|
var a: int = 8;
|
2014-06-26 01:45:44 -07:00
|
|
|
println(a);
|
2015-05-09 06:24:56 -04:00
|
|
|
var objPtr: ClassWithConstructor* = new<ClassWithConstructor>()->construct(11);
|
2014-06-26 01:45:44 -07:00
|
|
|
objPtr->printData();
|
|
|
|
|
delete<ClassWithConstructor>(objPtr);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|