Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Templated containers of inherited objects

Thread Tools

Templated containers of inherited objects

Emmanuel Deloget
Posts: n/a
On 18 fév, 15:31, Kai-Uwe Bux <(E-Mail Removed)> wrote:
> Hm, I always felt that this is simply because pointers are not really what
> we want when dealing with objects. What we want is something like a
> reference that can be assigned and re-seated. Something like this:

tr1::reference_wrapper? It will be incorporated in the next standard,
so let's use it (provided that those damn major compiler vendor gives
us a valid implementation of the tr1. As of today, it's quite hard to
use it in a portable way).

-- Emmanuel Deloget

Reply With Quote
Posts: n/a
On Feb 20, 1:40 am, Jerry Coffin <(E-Mail Removed)> wrote:
> In article <(E-Mail Removed). com>,
> (E-Mail Removed) says...
> [ ... ]
> > > OO is characterized by inherited and polymorphic objects. STL neither
> > > uses nor supports these.

> > OO is characterised by encapsulated objects that have internal state,
> > are responsible for their own behaviour and communicate through
> > message passing. The STL does follow this. This newer definition of OO
> > centred around inheritance is a direct result of Java and to a lesser
> > extent C++, but it has no historic basis.

> I see little basis for this claim. Consider, for example:
> Object-oriented programming is a method of implementation in
> which programs are orgainzed as cooperative collections of
> objects, each of which represents an instance of some class,
> and whose classes are all members of a hierarchy of classes
> united via inheritance relationships.
> That's from _Object-Oriented Analysis and Design: With Applications
> (Second Edition)_, Grady Booch, 1994. In the same book, use of objects
> but not inheritance is titled "Object-based".
> Going back even further:
> A subclass specifies that its instances will be the same
> as instances of another class, called its _superclass_,
> except for the differences that are explicitly stated.
> The Smalltalk-80 programmer always creates a new class as
> a subclass of an existing class. A system class named
> Object describes the similarity of all objects in the
> system, so every class will at least be a subclass of
> Object.
> _Smalltalk-80: The Language_, Adele Goldberg and David Robson, 1989.
> There is little or no historical support for the notion that use of
> objects in the absence of inheritance gives object oriented programming.
> The Standard Template Library was (and remains) largely template-based
> -- but C++ was considered an object-oriented programming language long
> before it supported templates at all.

Yes and no. If you analyse how hierarchy is used in the languages
you'll notice that there are fundemental differences. In Smalltalk it
is not possible to use hierarchy for type checking so it is used for
programmer convenience.

If you look at the way that the collection classes in Smalltalk are
implemented you'll notice that they're conceptually similar to the
collection classes in the STL. Smalltalk's collections work with
objects that implement a specific capability/method/operator (which
ones depend on the collection class), not because they are a sub-class
of a specified super-class.

In as much as inheritance is used for type checking it has not been
important in older OO system. For helping the programmer to re-use
code and organise the system it has been important. These days most
people equate hierarchy with type checking and that is what I'm saying
isn't a defining quality of OO.

For what it's worth I think Alan Kay agrees with me:
You'll notice that he never uses inheritance as part of his


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Are sequence containers not a subset of general containers? Sebastian Mach C++ 5 10-06-2012 07:54 PM
Proper use of templated containers as class members Per C++ 10 12-08-2008 09:46 AM
Containers of iterators vs. containers of references C++ 7 01-25-2008 01:37 PM
Subtypes of templated types (in templated functions) Marijn C++ 5 02-13-2004 09:50 AM
implementing a templated struct within a templated struct RA Scheltema C++ 3 01-06-2004 11:25 AM