M
Michael
Hello world,
many readers helped me with my struct query,
so I fell encouraged to post another question.
I wonder if linking functions via pointers
to structs is "a good idea". E.g. a stack
struct stack
{
/* some var in here */
void (*push)(<pointer to stack>, <object>);
};
/* ... */
struct stack test;
/* ... */
test.push(&test, <stuff>);
Since there is no "this" pointer in C (at least I
do not know), is there an advantage in using an object-
like structure (not only member-var but also functions
packed together)?
Well, or does it depend on the situation?
Thanks
Michael
many readers helped me with my struct query,
so I fell encouraged to post another question.
I wonder if linking functions via pointers
to structs is "a good idea". E.g. a stack
struct stack
{
/* some var in here */
void (*push)(<pointer to stack>, <object>);
};
/* ... */
struct stack test;
/* ... */
test.push(&test, <stuff>);
Since there is no "this" pointer in C (at least I
do not know), is there an advantage in using an object-
like structure (not only member-var but also functions
packed together)?
Well, or does it depend on the situation?
Thanks
Michael