TITLE: non-template vs template versions of functions (Newsgroups: comp.lang.c++.moderated, 22 Mar 98) ZIAUDDIN: Najeem Ziauddin [snip] > consider the following problem. > > template > void > foo(T) > { > cout< } > > template <> > void > foo(int ) > { > cout< } > > void > foo(int) > { > cout< } > > If i give a statement foo(int()) in the main function , the o/p is "in > special int". If I put the specialization below the function, then the > o/p will be "in int". VANDEVOORDE: David Vandevoorde Where is "the main function"? The fact that you "specialize the function template" is relatively unimportant. At the point where you call a 'foo' with an 'int' there are presumably two possibilities: (a) only the template version is visible (b) both the template and non-template version is visible If (a), there is no choice and you pick the template version. If (b), overload resolution finds that both are equal-rank candidates, but there is a rule that in that case non-templates are preferred over templates and hence you pick the non-template.