Home

On Sep 29, 7:06 am, Ian Collins <ian-n...@hotmail.com> wrote:
> subramanian10...@yahoo.com, India wrote:
> > Consider

> > template <typename T>
> > void compare_and_print(const T & arg1, const T & arg2)

> > template <class T>
> > void compare_and_print(const T & arg1, const T & arg2)

> > If I use any one of these two, the compiler accepts it. That is, the
> > compiler accepts both "typename T" and "class T" inside the angle
> > brackets <>. Which form is correct ?

> Both.

> "class T" was the pre-standard way of specifying a template
> parameter, "typename T" was added because a template parameter
> is a typename, not necessarily a class.

Just a nit, but what actually happened is that class was
originally used, to avoid introducing yet another keyword. When
the keyword typename was introduced for dependent names, it was
decided that it would also be appropriate to allow it here.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

previous
next

Re: array as member of class
Re: beginner in python
Re: deletion of mem alloated using placement new
Setting default output encoding
Re: Howto rethrow an exception outside a catch block?
Fundacja Hobbit
Dzieci Niczyje
Mimo Wszystko
Podaruj Zycie
Fundacja Iskierka