What do you think? Are pure virtual classes a good idea for maintaining
platform independence in a class library?

Linux uses C and header files to maintain platform independence. It uses
#ifdef sparingly. Platform dependent subroutines are pushed out into their
own directories. All the platform-specific subroutines for a platform are
in a directory together.

When platform-independent code calls a subroutine declared in a header, it
doesn't matter (much) if the implementation is platform-independent or
platform-specific. The linker takes care of linking in the right machine
code for a platform.

When dealing with classes, you can quickly run into trouble if you define
fields in a platform-independent class. The fields for one platform might
not be suitable for another. Pure virtual classes are like the Java-style
interface. The define the behavior a class is supposed to have; but, it
does not allocate any fields.

While it might look like more work to define two classes for common objects
instead of one, it is less likely that common objects will need to be
revised in the future to accommodate a new platform.


_______________________________________________
Kernel maillist  -  [EMAIL PROTECTED]
http://jos.org/mailman/listinfo/kernel

Reply via email to