QUOTE(NickDMax @ 18 Oct, 2007 - 06:01 PM)

well I am not a compiler designer nor really studied advanced language structures etc, but I do know that the
Comeau C++ compiler actually compiles C++ into C. The point being that there is nothing all that mysterious and amazing about Objects. They represent some pretty complicated uses of pointers but they are just an application of pointers and structures.
yeah that's true. It would be just plain ugly to code it in C. Why not just use C++? And I think the resulting C code isn't too complicated. I'm just studying compiler construction and if I had to make Objects (if I compile it down to C code) I'd just make a struct and replace the function calls from the object with a normal C function call
CODE
#include <stdio.h>
struct obj {
int a;
};
int objFunc(struct obj* this, int b) {
return this->a * b; // return a * b;
}
int main(int argc, char *argv[]) {
struct obj a; // obj a = new obj();
a.a = 10;
int b = objFunc(&a, 5); // a.objFunc(5);
printf("%d\n", b);
return 0;
}
tadaaa and there we have the this keyword
This post has been edited by Kiriran: 20 Oct, 2007 - 04:09 AM