2014-06-26 01:45:44 -07:00
|
|
|
import io;
|
|
|
|
|
import mem;
|
|
|
|
|
|
|
|
|
|
typedef ClassWithConstructor {
|
2014-08-01 00:45:48 -07:00
|
|
|
|int| data;
|
|
|
|
|
|ClassWithConstructor*| construct(|int| inData) {
|
2014-06-26 01:45:44 -07:00
|
|
|
data = inData;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2014-08-01 00:45:48 -07:00
|
|
|
|void| printData() {
|
2014-06-26 01:45:44 -07:00
|
|
|
println(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-01 00:45:48 -07:00
|
|
|
|int| main() {
|
|
|
|
|
|ClassWithConstructor| object.construct(4);
|
2014-06-26 01:45:44 -07:00
|
|
|
//ClassWithConstructor object;
|
|
|
|
|
//object.construct(4);
|
|
|
|
|
object.printData();
|
2014-08-01 00:45:48 -07:00
|
|
|
|int| a = 8;
|
2014-06-26 01:45:44 -07:00
|
|
|
println(a);
|
2014-08-01 00:45:48 -07:00
|
|
|
|ClassWithConstructor*| objPtr = new<ClassWithConstructor>()->construct(11);
|
2014-06-26 01:45:44 -07:00
|
|
|
objPtr->printData();
|
|
|
|
|
delete<ClassWithConstructor>(objPtr);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|