From: "John Bodfish" Newsgroups: comp.os.msdos.djgpp Subject: Re: Containers/Templates etc Date: 13 Nov 1997 16:03:48 GMT Organization: Ameritech Library Services Lines: 35 Message-ID: <01bcf04d$8cd74f00$b8cde7c0@JOHNB.als.ameritech.com> References: <199711121934 DOT OAA22789 AT delorie DOT com> NNTP-Posting-Host: n5184.als.ameritech.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk sl 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 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) *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