> One possibility seems to be to make the flag
> array into a base class for the array class - in that
> case all the methods are automatically inherited,
> with no need to put them explicitly into the
> array interface.
>
> But that public inheritance doesn't model an
> "isa" relationship, so is it automatically
> bad?
Why not just make the flag array a member of the array class
and have a method flags() that returns a reference to the flags.
This is appropriate for a "has a" relationship.
It's a nuisance to have to type flags() every time, but it does
indicate the "has a" relationship correctly and requires adding
at most two members for the interface: "flags()" and "flags() const".
Ten years of experience with C++ has taught me to steer clear
of clever hacks merely to avoid typing a little extra.
And invariably the hacks give license to the compiler to do
implicit conversions that I end up regretting.
Arch D. Robison Kuck & Associates Inc.
robison@kai.com 1906 Fox Drive
217-356-2288 ext. 56 Champaign IL 61820
Lead Developer for KAI C++ http://www.kai.com/C_plus_plus/index.html
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:07 EST