J
James Emil Avery
Hi all,
I have a problem where
1. I have many derived classes of a base class.
2. The base class has many functions implementing common behaviour.
3. The code should be the same for all the derived classes, but the
unctions depend on *static, constant data* that is specific to each
erived class.
4. I cannot declare this static data virtual, because I must also be able
to instantiate the base class; I.e. I must have the static data in the
base class as a fall-back.
My problem: I override the data in the derived classes, but the common
functions still use the data from the base class.
I do not wish to duplicate the base-class functions to all the many
derived classes, because of the unnecessary blow-up of code size,
decreased readability and maintenance. I also want to keep the data
static, since memory requirements would otherwise drastically increase.
Is there any way in C++ that makes this setup possible? I.e. have code
that is shared between all derived classes, but which depends on data that
is specific to each derived class?
Thanks very much in advance.
I have a problem where
1. I have many derived classes of a base class.
2. The base class has many functions implementing common behaviour.
3. The code should be the same for all the derived classes, but the
unctions depend on *static, constant data* that is specific to each
erived class.
4. I cannot declare this static data virtual, because I must also be able
to instantiate the base class; I.e. I must have the static data in the
base class as a fall-back.
My problem: I override the data in the derived classes, but the common
functions still use the data from the base class.
I do not wish to duplicate the base-class functions to all the many
derived classes, because of the unnecessary blow-up of code size,
decreased readability and maintenance. I also want to keep the data
static, since memory requirements would otherwise drastically increase.
Is there any way in C++ that makes this setup possible? I.e. have code
that is shared between all derived classes, but which depends on data that
is specific to each derived class?
Thanks very much in advance.