Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-01-07 14:30:09


> > Why is it considered better to model a concept rather than inherit from
a
> > base class and override a virtual function? It seems to me that it is
> > simpler to explain to a newcomer to inherit from a class, and it is more
> > apparent from looking at the code what is actually happening.
>
> If I already have a function (object) that provides the desired
> output, why must I create a class, implement a member function
> that forwards to that function(object), and then use the class?
> A simple call to make_filter(f) will do the job without the need
> to write any code.

Innheritance is a strongest relationship and shouldn't be used unless really
needed. That what we learn from the expirience with modern C++ and from C++
experts (see recent Sutter books for example).

Among other things your implementation employ runtime polimorpism for no
particular reason IMO.

Gennadiy


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