Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2004-01-22 13:35:02


Pavel Vozenilek ha escrito:

> "Joaquín Mª López Muñoz" <joaquin_at_[hidden]> wrote
>
> > If you accept this [no delete], I see no problem in *publicly* deriving
> > A_with_data from A and use the former as a substitute of the latter:
> >
> There's one implicit assumption in this approach: user won't overwrite
> (non-virtual) interface of container, e.g. no push_back() with logging
> # of calls.
>

Of course, but this is precisely the case of your proposal: adding
some attached data to the base class does not change its interface
at all.

>
> But this is not enforceable technically and having derived class makes it
> tempting 'just to add some little functionality'.
>
> The solution I have in mind is more complicated (for library writer)
> but safer (IMHO) agains misuse.
>

I think we basically agree. If you overwrite some method of the
base class interface, then public derivation should be banned.
Again, I think this is not the case for the particular situation
we are discussing.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk