I'm trying to implement some kind of OOP in C. I have a struct Foo that has a funcion pointer to some function:
struct Foo
{
void (*func)();
};
The problem here is that every instance of this type will have this pointer which takes space and if I were to add more function pointers (and for a typical struct I usually create a lot of them) them my program will consume way more memory. What is the generally accepted way to get around this increased memory consumption? How do object-oriented languages handle this? And how do implement that in C?