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:
Nathan Braswell
2014-06-26 01:45:44 -07:00
parent 82d8a15de0
commit 63d9ec66e1
7 changed files with 134 additions and 50 deletions

View File

@@ -0,0 +1,3 @@
4
8
11

View 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;
}