Name: Anonymous 2013-07-15 8:43
/Prog/, just a minute of your time, please. I'm reading a book and it has a piece of C code like this:
I'm trying to compile it and it doesn't work, I'm guessing it's because the book is old. How do you do that type of thing in modern C? I.e. define a struct with a pointer to a function that takes a pointer to a struct you're defining.
typedef struct {
void (*print) (struct * shape);
// data fields
} shape;I'm trying to compile it and it doesn't work, I'm guessing it's because the book is old. How do you do that type of thing in modern C? I.e. define a struct with a pointer to a function that takes a pointer to a struct you're defining.