J
Jess
Hello,
I learned that when I work with templates in C++, I should have
functions that pass arguments by reference because the type of object
is not known. Does it mean that if I have a function that is template
function, then it's argument should be a reference type, such as the
following?
template<class T>
void f(T& t){...}
What if I replace the signature by
template<class T>
void f(T t){...}
or
template<class T>
void f(T* tp){...}
Would it work and if not, could someone tell me why please?
Thanks,
Jess
I learned that when I work with templates in C++, I should have
functions that pass arguments by reference because the type of object
is not known. Does it mean that if I have a function that is template
function, then it's argument should be a reference type, such as the
following?
template<class T>
void f(T& t){...}
What if I replace the signature by
template<class T>
void f(T t){...}
or
template<class T>
void f(T* tp){...}
Would it work and if not, could someone tell me why please?
Thanks,
Jess