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