template question

May 11, 2009 at 9:25pm
Hello Friends,
I want to ask , Can we use template functions without using any class ? If yes , how ?

thank you !
Last edited on May 11, 2009 at 9:26pm
May 11, 2009 at 9:34pm
Yes.

http://cplusplus.com/doc/tutorial/templates/

See the "GetMin" example on that page.
May 11, 2009 at 11:32pm
The class inside the <> is just a keyword used by templates, it doesn't mean that the function can take only classes at their template parameters. For example, this would be a valid call to that function:
int a=GetMin(1.25,4);

A synonym for class in that context is typename, by the way.
Last edited on May 11, 2009 at 11:32pm
May 11, 2009 at 11:33pm
To mischt/jayt: So you have two accounts (at least)?

To all:
jayt == mischt
He accidentally posted a response as mischt here, then deleted it and reposetd it as jayt, then deleted that post. I just happened to see it. :)
May 12, 2009 at 12:06am
lol?
May 12, 2009 at 1:13am
yeh helios ! I got it Thanks
Topic archived. No new replies allowed.