template function

what is template function and how it is overloaded .. with syntax ..please reply soon... thank you ...
http://cplusplus.com/doc/tutorial/templates/

how it is overloaded

Do you mean, "how is it specialised?". That is covered in the above tutorial.

Template functions are overloaded in exactly the same way as normal functions:
1
2
3
4
5
6
7
8
9
template <class A> void foo()
{

}

template <class A> void foo(float f)
{

}

However, if you want to overload a template specialisation, it seems that the overload must match one of the template overloads:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
template <class A> void foo()
{

}

template <class A> void foo(float f)
{

}

template<> void foo<int>() // allowed: matches the first template
{

}

template<> void foo<int>(float f) // allowed: matches the seconds template
{

}

template<> void foo<int>(const char*) // not allowed: does not match any template
{

}
Topic archived. No new replies allowed.