August 2012
Intermediate to advanced
976 pages
30h 17m
English
Like the names of function parameters, a template parameter name has no intrinsic meaning. We ordinarily name type parameters T, but we can use any name:
template <typename Foo> Foo calc(const Foo& a, const Foo& b){ Foo tmp = a; // tmp has the same type as the parameters and return type // ... return tmp; // return type and parameters have the same type}
Template parameters follow normal scoping rules. The name of a template parameter can be used after it has been declared and until the end of the template declaration or definition. As with any other name, a template parameter ...
Read now
Unlock full access