i hope when i give, say, 10, 10.0, the program would choose #1, and when i give "hey", it will choose #2, but the result is that, it still choose #1, only when i give variable whose type is char* will choose #2.
i was told "hey" and char* x; both char* type and cause they are actually the addr. i'm puzzled...
and how i code is the right way?
The downside to preferring overloading over specializing is that you can still call the template version if you explicitly specify the template args (which may sometimes be necessary to avoid ambiguities)
1 2 3 4 5 6 7 8 9 10
template <typename T> void f(T); // (a)
void f(int); // (b)
template <typename T> // for this example, assume T=int
f<T>(foo); // calls (a), not (b)
Obviously this is a trivial example because <T> doesn't need to be explicitly specified here... but sometimes it needs to be.