Derived classes in C - What is your favorite method?

后端 未结 9 1253
既然无缘
既然无缘 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条回答
  •  生来不讨喜
    2020-12-17 04:37

    At a former job, we used a preprocessor to handle this. We declared classes using a simple C++-style syntax, and the preprocessor generated C headers that were basically equivalent to the First Method, but without the #includes. It also did cool things like generating vtables and macros for upcasting and downcasting.

    Note that this was in the days before good C++ compilers existed for all the platforms we targeted. Now, doing this would be stupid.

提交回复
热议问题