Mail Archives: djgpp/1997/06/09/05:32:50
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 -