Boost logo

Boost :

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

Hi Daniel

"Daniel Krügler (nee Spangenberg)" ha escrito:

> >
> > IMHO, deletion needs extra considerations apart from
> > the issue of non-virtual derivation, so it is not so
> > bad to apply derivation here. Main benefit is you
> > can use this idiom with preexisting classes.
> >
> > Joaquín M López Muñoz
> > Telefónica, Investigación y Desarrollo
> The usually acceptable inheritance-for-reuse (inherit-implementation
> or WAS-A) idiom would derive protected or private, so you can't
> use the wrong delete (at least for private inheritance), but you have
> to publish all necessary base members via in-class using-declaration.

But having to using-declare everything renders this approach
practically unuseful!
I'll try to better explain my point wrt to inheritance for reuse:

Consider a class A: then an "A*" in general NOT-IS-A
"deletable A*": you must know where the pointer came from to
make sure you can delete it. Virtuality considerations
aside, the object could be stack-allocated and the program
has no way to distinguish it from a deletable pointer.

If you accept this, I see no problem in *publicly* deriving
A_with_data from A and use the former as a substitute of the latter:
  * The semantics of A is completely preserved in A_with_data
  * The state of A_with_data cannot be damaged due to
  usage of the A interface alone.
  * You might have problems with deletion, but hey those problems
  already exist with plain A objects.

See what I mean?

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

Boost list run by bdawes at, gregod at, cpdaniel at, john at