Object-orientation in C

前端 未结 22 1706
孤城傲影
孤城傲影 2020-11-22 15:26

What would be a set of nifty preprocessor hacks (ANSI C89/ISO C90 compatible) which enable some kind of ugly (but usable) object-orientation in C?

I am familiar with

22条回答
  •  长发绾君心
    2020-11-22 16:25

    If you need to write a little code try this: https://github.com/fulminati/class-framework

    #include "class-framework.h"
    
    CLASS (People) {
        int age;
    };
    
    int main()
    {
        People *p = NEW (People);
    
        p->age = 10;
    
        printf("%d\n", p->age);
    }
    

提交回复
热议问题