There's the C++ language and there's the preprocessor. Both have their place in software development. To put it simply, classes, inheritance and polymorphism are used to solve problems which need to be resolved at run-time. Preprocessor can be used to solve problems that need to be resolved at compile-time. If you define derived classes for different environments, your code will probably not even compile, because the windows code won't compile on linux and vice versa. There probably are cases where it could work, such as if the reason for different approaches on different platforms is the methods' efficiency, rather than their availability, but in most cases, the #ifs are the way to go.
|