Im kind of stuck on this. I read in a book that we can make Generic functions with function template but on other places, author called the generic function, an function template. witch is proper for example:
template <class T> void printSmt(T x){}
in here printSmt
is called generic function or function template?
And another question: is x
in parameter list of function printSmt
a generic type or a template parameter?
EDIT: im writing some documents for my school. if it's possible give me an answer according to C++ reference.
The C++ Standard calls it function template. The term generic function is more used in other object-oriented languages (e.g. in LISP these are functions with the same name). Java uses generic types to implement a minimal approach of generic programming.
x
is the function parameter. T
is the template parameter. In printSmt<int>()
int
is the template argument.