[prog] C++ Templates

Katie Lucas katie at fysh.org
Wed Nov 12 11:59:49 EST 2003


On Thu, Jun 26, 2003 at 10:50:21PM +1000, Sue Stones wrote:
> 
> 
> On Thu, 26 Jun 2003 10:33 pm, Christine Bussman wrote:
> > Please note that I'm just a beginner myself, so these are
> > just the things I would try myself, or things that look
> > wrong to me.  I'm also looking at a text I've used in the
> > past.
> 
> thanks for your comments Christine, you have obviously written a template 
> before,
> so you are more experience than me!
> 
> > 1.  I've always used template <class T> rather than
> > <typename T>, I don't know if this will make a difference
> 
> On this fact I know for sure that it makes no difference.  That is clear from
> the books, and both pass the compiler.

There is a difference, but frankly I can't quite recall what it's
supposed to be. The effect of the difference is to delay some type
resolution until later in the instantiation. This is only really
relevant if you're trying to do perverse things involving nested
templates where you need access to the namespace of the template
parameter.

When you're learning C++, you almost certainly want "class" instead of
"typename". I went about 7 years as a commercial C++ developer
before I needed "typename"...



More information about the Programming mailing list