Plant
, FlowerMixin
, and
FruitVegetableMixin
.
He then goes on to define other classes as follows:
class Rose: public Plant, public FlowerMixin ... class Carrot: public Plant, public FruitVegetableMixin ... class Cherry: public Plant, public FruitVegetableMixin, public FlowerMixin ...
int
, float
, and
char
are indeed types in the C++ language, however, they
certainly do not represent classes.
One cannot inherit representation or behavior from these types, but one may
use them as aggregate elements of new classes.
.h
file will necessitate a recompilation of
any piece of code including that .h
file.
Inventory
class which can contain
heterogeneous objects, that is, objects having different types.
I do not recommend that one enter into such activities lightly. There
be dragons there.
There is now a proposal for ANSI C++ that contains a mechanism for
run-time type identification (RTTI), however, using such types can
often lead to a less O-O programming style, in which myriad switch
control structures checking the types of objects are employed.
having such code structures does not lead to easily modifiable, highly
maintainable programs.
The first mechanism would usually be employed if B is considered to be the more complicated type. The second would be employed if B were considered to be the simpler type.