Derived classes in C - What is your favorite method?

后端 未结 9 1234
既然无缘
既然无缘 2020-12-17 04:10

In my experience in object oriented C programming I have seen two ways to implement derived classes.


First Method, have a definition of the pa

9条回答
  •  萌比男神i
    2020-12-17 04:36

    The first method is hideous and it hides important information. I'd never use it or allow it being used. Even using a macro would be better:

    #define BODY int member1; \
                 int member2; 
    
    struct base_class
    {
       BODY
    };
    

    But method 2 is much better, for reasons others have pointed out.

提交回复
热议问题