Did you ever try?
How to Pass a Polymorphic Object to an STL Algorithm
by Jonathan Boccara
From the article:
As we can read in the opening chapter of Effective C++, C++ is a federation of 4 languages:
- the procedural part coming from C,
- the object-oriented part,
- the STL part (following a functional programming paradigm),
- the generic part with templates.
And what’s more, all of those 4 sub-languages are part of one whole: the C++ language. Those 4 paradigms begin united in one language gives opportunities for them to interact – and often, those interactions create interesting situations.
Today we’re focusing on one particular interaction, between the object-oriented model and the STL. There could be multiple forms for this interaction, and the case we will look at is how to pass a polymorphic (that is, having virtual methods) function object to an STL algorithm.
Add a Comment
Comments are closed.