Object Oriented C Programming
You may have noticed that our structs are a bit strange with many function pointers, like the following:
typedef struct Vector
{
const size_t block_size;
int * data; // the memory block
size_t capacity; // size of the memory block
size_t size; // length of the vector
void (*create)(struct Vector * self);
void (*delete)(struct Vector * self);
int (*get)(struct Vector * self, size_t index);
void (*set)(struct Vector * self, size_t index, int value);
void (*add_at)(struct Vector * self, size_t index, int value);
int (*remove_at)(struct Vector * self, size_t index, int value);
} Vector;
This is actually a tecnique called Object Oriented C
For tutorial you can read
For more detailed books, you can read
Last updated