c++ - passing pointer type to template argument -
i wrote following code:
template <typename t> void myname(t* x) { cout<<"x "<<x; } and invoked:
char *p="stackoverflow"; myname(p); it prints stackoverflow.
but if change template argument (t* x) (t x) same result.
so difference between 2 template parameters?
void myname (t x) and
void myname (t* x)
first case - t deduced char, t* char*. second case - t deduced char*. differences here in call such function
for first case should be
myname<char>(p); and second
myname<char*>(p); also, differences when use type t in function.