Re: Templated containers of inherited objects
On Feb 18, 2:12 am, rpbg...@yahoo.com (Roland Pibinger) wrote:
On 16 Feb 2007 17:29:09 -0800, paul joseph wrote:
STL containers,
iterators and algorithms are designed only for values, not for
(pointers to) objects.
This is just wrong. A pointer *is* a value. Its a memory address. STL
containers will work just fine with pointers.
A pointer is not a value, otherwise one could just use an int instead.
A pointer in C/C++ has the combined meaning of reference and address.
What is your definition of 'value' that makes you say that a pointer
isn't a value? After all a pointer *is* just an integer, but one which
is interpreted in a specific way (old x86 style far pointers
notwithstanding), but that is the same as many other value types too.
In general, STL is the attempt introduce the functional paradigm into
the C++ language as counterpart to the object-oriented paradigm. This
attempt has produced much misunderstanding and confusion.
I've come across this assertion a couple of times. To me the STL is a
fine bit of OO programming, but I can see where the functional view
comes into it too.
The use of generic containers and the ability to perform operations no
them has been part of both functional languages and OO languages up
until early C++ and Java. What the STL doesn't do though is to enforce
the 'no side effect' rule from pure functional programming languages.
To me this puts it firmly on the OO side. It isn't really doing
anything that the containers in Smalltalk don't do and I'm not sure
that anybody would claim them to be a functional paradigm.
K