How can I simulate OO-style polymorphism in C?
The first C++ compiler (“C with classes”) would actually generate C code, so that’s definitely doable. Basically, your base class is a struct; derived structs must include the base struct at the first position, so that a pointer to the “derived” struct will also be a valid pointer to the base struct. typedef struct { … Read more