c objects
C
code posted
created at 04 Feb 04:07
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
typedef struct MyObject MyObject; struct MyObject { void (*action)(int, char*); }; static void my_object_action(int i, char *s) { printf("%i: %s\n", i, s); } MyObject* my_object_new(void) { MyObject *my = malloc(sizeof(MyObject)); my->action = &my_object_action; return my; } |
314 Bytes in 2 ms with coderay