class test {
public:
test();
void tester(int a);
private:
int s;
};
Interesting thought....
Hello.
I am having this thought... Can i combine a bunch of functions in a sort of an object, i mean under "C", and pure "C".
Basically, translate this to "C":
Thanks in advance!
Function Pointers. Take a look at the Quake 3 source. Its done a lot of times, obviously you wont have inheritance and such, but you can cheat.
Also, my syntax may be wrong, I don't frequently use function pointers.
struct test{ void (*test)(); void (*tester)(int a); int s;}
Also, my syntax may be wrong, I don't frequently use function pointers.
The way to do that is to have a series of global functions which act on a handle to the instance (either a pointer to a struct, or an opaque value).
Quote:Original post by Catafriggm
The way to do that is to have a series of global functions which act on a handle to the instance (either a pointer to a struct, or an opaque value).
Or that...
Quote:Original post by Catafriggm
The way to do that is to have a series of global functions which act on a handle to the instance (either a pointer to a struct, or an opaque value).
Can you please explain a bit more...
Quote:Original post by Ancient SpiritQuote:Original post by Catafriggm
The way to do that is to have a series of global functions which act on a handle to the instance (either a pointer to a struct, or an opaque value).
Can you please explain a bit more...
struct test{ int s;}void test_test(test& object){ s = 0; return;}void test_tester(test& object, int a){ s = a; // ? return;}
Quote:Original post by Ancient Spirit
i dont think u can use the "&" in "C"
picky picky people, this is what I get for being a pure C++ programmer
struct test{ int s;};void test_test(test* object){ object->s = 0; return;}void test_tester(test* object, int a){ object->s = a; // ? return;}
And I fixed a bug aswell. Now fixed the real bug.
[Edited by - Richy2k on October 9, 2005 7:17:13 PM]
No, you can't, but you can replace it by a pointer.
[edit] Fixed at time of writing.
[edit2] And don't forget to actually use the pointer... ->
jfl.
[edit] Fixed at time of writing.
[edit2] And don't forget to actually use the pointer... ->
void test_tester(test* object, int a){ object->s = a; return;}
jfl.
Here are a couple of links that might help.
Object-Oriented C: Creating Foundation Classes Part 1
Object Oriented Programming in C
Object Oriented Programming in C
Here's a complete book on the subject: Object-Oriented Programming With ANSI-C (pdf)
If you want to get an idea of how vtables are constructed, if you have access to a Windows based compiler, open the iunknown.h in a text editor and examine what it does with structures, forward references, and function pointers. You might also have to search for macro definitions in other headers.
Object-Oriented C: Creating Foundation Classes Part 1
Object Oriented Programming in C
Object Oriented Programming in C
Here's a complete book on the subject: Object-Oriented Programming With ANSI-C (pdf)
If you want to get an idea of how vtables are constructed, if you have access to a Windows based compiler, open the iunknown.h in a text editor and examine what it does with structures, forward references, and function pointers. You might also have to search for macro definitions in other headers.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement