Feb 21, 2009 at 10:50pm UTC
Hey guys, just wondering what the difference is with this:
1 2 3 4 5 6 7 8 9 10 11
template <class T>
class GiveValues
{
public :
T values [2];
GiveValues (T first, T second)
{
values[0]=first;
values[1]=second;
}
};
and
1 2 3 4 5 6 7 8 9 10 11
template <typename T>
class GiveValues
{
public :
T values [2];
GiveValues (T first, T second)
{
values[0]=first;
values[1]=second;
}
};
as they both have the same outcome?
Last edited on Feb 21, 2009 at 10:51pm UTC
Feb 21, 2009 at 10:55pm UTC
The only difference between both prototypes is the use of either the keyword class or the keyword typename. Its use is indistinct, since both expressions have exactly the same meaning and behave exactly the same way
from
http://www.cplusplus.com/doc/tutorial/templates.html
As the name suggests, using typename
you have to type for a longer name...
Last edited on Feb 21, 2009 at 11:01pm UTC
Feb 22, 2009 at 12:45am UTC
Cheers for that - as you can see the above code is from that tutorial - but I must have skipped that paragraph.
Thanks Bazzy ;)