C++: compile time conditional inheritance

From: Doru-Catalin Togea (doru-cat_at_ifi.uio.no)
Date: 02/14/04


Date: Sat, 14 Feb 2004 17:58:34 +0100

Hi!

I'm using Redhat 9.0 with GCC 3.2.

I have three classes which all implement different kinds of "Module"
objects.

In my application I have objects which must inherit any ONE of the Module
classes.

How do I tell the compiler how to chose a particular class at compile
time? My goal is to be able to easily build the application with objects
based on any of the available Module classes.

Say I have classA, classB and classC. I'm thinking that maybe by declaring
an environment variable and setting its value to say "A", "B" or "C" I
could direct my compilation to link in the right class. Or can I get the
job done with only "#ifdef"s?

I want to easily make the compiler see either

class MyObject : public classA {...}; or
class MyObject : public classB {...}; or
class MyObject : public classC {...};

without having to change programme code.

Thanks if anyone can help.
Catalin

-- 
        <<<< ================================== >>>>
        <<     We are what we repeatedly do.      >>
        <<  Excellence, therefore, is not an act  >>
        <<             but a habit.               >>
        <<<< ================================== >>>>