M
Mick Charles Beaver
Hello,
At work, someone showed me a way to avoid virtual functions while
maintaining an interface class.
Basically,
class _MyClass {
void Method;
};
#if defined(LINUX)
#include "linux/MyLinuxClass.h"
class MyClass : public MyLinuxClass {};
#elif defined(WINDOWS)
#include "windows/MyWindowsClass.h"
class MyClass : public MyWindowsClass {};
#endif
Then, throughout the code base, MyClass would be used, following the
interface defined in _MyClass, while still allowing platform-specific
code where needed.
My question is, where could I read about more constructions like this?
My coworker called it an "inheritance pattern." I'd love to learn more
about them (even though I'm sure a case can be made for avoiding this
style).
Thanks much,
Mick Charles Beaver
At work, someone showed me a way to avoid virtual functions while
maintaining an interface class.
Basically,
class _MyClass {
void Method;
};
#if defined(LINUX)
#include "linux/MyLinuxClass.h"
class MyClass : public MyLinuxClass {};
#elif defined(WINDOWS)
#include "windows/MyWindowsClass.h"
class MyClass : public MyWindowsClass {};
#endif
Then, throughout the code base, MyClass would be used, following the
interface defined in _MyClass, while still allowing platform-specific
code where needed.
My question is, where could I read about more constructions like this?
My coworker called it an "inheritance pattern." I'd love to learn more
about them (even though I'm sure a case can be made for avoiding this
style).
Thanks much,
Mick Charles Beaver