Mail Archives: djgpp/1997/11/13/13:46:29
sl <SL AT usemail DOT com> wrote in article <199711121934 DOT OAA22789 AT delorie DOT com>...
> On Wed, 12 Nov 1997 14:38:01 +0200, eyal DOT ben-david AT aks DOT com wrote:
>
> >Hello Gili
> >
> >Container is a data structure that *contains* other objects. For
example,
> >your Array<int> above is a container of ints.
>
> But then, according to you, templates ARE containers. That's weird, are
they 100% the same?
>
> >The standard library has many container classes (all in the form of a
> >template)
> >for example: vector, list, deque, set, and many more.
>
Your example of a template (Array<int>) *happened* to also be an example of
a
Container template. But it is possible to design a template which is not a
container; for example the STL has a min function template which returns
the
"lesser" of two objects, no matter what the datatype you supply; even if
its
a class of your own devising. The only requirement is a "operator<" defined
for the class. (Or you can supply a comparison function.) It's easy to get
confused between Container and template, since the most commonly discussed
of the STL's templates are containers.
--
John Bodfish
bodfish AT als DOT ameritech DOT com
- Raw text -