Re: Solving the data inheritance problem
Kaba wrote:
A more concrete example would be appreciated. Form follows
function, and it is difficult to determine the best form is we
don't know the function.
Hello James, there is a concrete example on the other post I sent.
I saw it. It looks very much like a case where the template
method pattern is the classical solution.
A straightforward solution is the following: place the data in A and
implement the (non-virtual) handling functions there. I call this data
inheritance.
The standard nomenclature calls it the template method pattern.
Here it is the intent that the common behaviour is not dependent on
subclasses, that is, does not use virtual functions.
That seems rather obvious. The behavior which is common is in
the base class; that which isn't is relegated to the derived
class. (And if there is no behavior which is not common, of
course, you don't need to derive.) That's the principle behind
the template method pattern.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]