Boost logo

Boost :

From: Marco Costalba (mcostalba_at_[hidden])
Date: 2007-10-08 00:59:48


On 10/7/07, Simonson, Lucanus J <lucanus.j.simonson_at_[hidden]> wrote:
> Marco wrote:
> >For what I can understand you have one class 'b' in B library that you
> >want to use with alghoritms of _both_ A and B library the pattern is:
> >
> >1 - get the class 'a' subclassing 'b'; class a : b
> >2 - add to 'a' interfaces to deal with algorithms of library A
> >3 - implement that interfaces using methods of 'b' and/or functions of
> >library B acting on 'b'
> >4 - use 'a' with library A using the above interface
> >5 - use 'a' with library B because base class of 'a' is a 'b'
> >Is this interpretation correct ?
>
> Yes, though I would add that the intention is to use it with classes b1
> through bN of libraries B1 through BN so that the effort of making the
> library generic is worthwhile. Class a inherits from each of the
> classes b1 through bN through its template parameter. In this way it is
> as useful as making class a the common base class of b1 through bN, but
> is not intrusive and leaves the code of libraries B1 through BN
> untouched. This inheriting one class from many allows us to unify the
> disparate semantics of many different types that are conceptually
> similar. I have found it very useful in my day to day work since I end
> up being the person integrating my library into existing code bases in
> addition to authoring it.
>

If I can ask, why do you preferred subclassing instead of composition?
Could 'b' be a member of 'a' instead?

Perhaps to access protected members of class b otherwise inaccessible?

In another part of your thread you say inerithance is public just
because of a limitation in MS compiler, so your intention would be to
use private inerithance, so you don't think at 'a' as is 'b' but in is
implemented in terms of 'b', is this correct?

Thanks
Marco


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