From: nee Spangenberg (dsp_at_[hidden])
Date: 2004-01-22 10:46:08
Hi Joaquín, (I hope that is not bad style in your home country)
Joaquín Mª López Muñoz schrieb:
> But having to using-declare everything renders this approach
> practically unuseful!
That depend on the class. But I am quite sure what you mean.
> 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?
Yes, I think so. If you narrow your requirements on classes, where
you demand, that using them polymorphically, is a programmers
error, than you can derive from it publicly.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk