Added "Init Position Call" (takes the place of implicit constructors) and the this keyword! This was the structure needed for more sensable memory management. At least delete will need some updating before it becomes very usable, though. (Figuring out the types for function template instantiation) Anyway, good progress here!
This commit is contained in:
3
tests/declarationsTest.expected_results
Normal file
3
tests/declarationsTest.expected_results
Normal file
@@ -0,0 +1,3 @@
|
||||
4
|
||||
8
|
||||
11
|
||||
26
tests/declarationsTest.krak
Normal file
26
tests/declarationsTest.krak
Normal file
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user