Functional pattern or Gereric function - correct term?

I am stuck on this. I read in the book that we can create common functions with a function template, but elsewhere, the author has called a common function, a function template. witch is suitable for example:

template <class T> void printSmt(T x){}

      

here printSmt

called a generic template for a function or function?

And one more question: is there a generic type or template x

parameter in the function parameter list printSmt

?

EDIT: I am writing some docs for my school. if possible please give me an answer as per C ++ recommendation.

+3


source to share


1 answer


The C ++ standard calls its function template. The term generic function is more used in other object-oriented languages ​​(for example, in LISP, these are functions of the same name). Java uses generic types to implement a minimal generic programming approach.



x

is a function parameter. T

is a template parameter. Into printSmt<int>()

int

the template argument.

+4


source







All Articles