delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/09/05:32:50

From: lonniem AT cs DOT utexas DOT edu (Lonnie McCullough)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Templates
Date: Mon, 09 Jun 1997 04:39:23 GMT
Message-ID: <339b876b.806033@news.nol.net>
References: <3 DOT 0 DOT 16 DOT 19970608164854 DOT 2e3f02e6 AT hem1 DOT passagen DOT se> <3399D9C3 DOT 2DB0 AT xl DOT ca>
NNTP-Posting-Host: ip38-42.nol.net
Lines: 30
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Sat, 07 Jun 1997 14:59:31 -0700, Darren Grant <darn AT xl DOT ca> wrote:

>Peter Palotas wrote:
>> 
>> I have been wondering for quite some time what templates are. I have seen
>> in some headerfiles in STL (I think) something like Class foo<t> and now I
>> am wondering what this is. I would be very grateful if someone could tell
>> me where I could read about this stuff, or just tell me what it is and how
>> it can be used.
>
>
>Templates provide a way of passing datatypes as parameters in C++. 
>Consider the simple function sum() below, that takes two ints as
>parameters and returns their sum:
>...
<excellent description of templates snipped>

A good on-line source to find out more about templates would probably
be comp.lang.c++ (or any of the other c++ newsgroups).  To elaborate
just a little: templates provide a layer of abstraction in situations
where the programmer is building data independent classes (lists are a
very limited but prime example of a good use of templates).  They are
also good, as Darren pointed out, in sum and min / max roles where a
simple #define MIN / MAX ... whatever might have adverse side effects.




Lonnie McCullough
lonniem AT cs DOT utexas DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019