(upbeat music)
- [Instructor] Our challenge for this chapter
was to create a template function,
for the non-recursive factorial challenge from chapter five.
Here's my solution, this is 07_ solution
from chapter seven of the exercise files,
and you notice my template function here,
it's using type name T, and it returns T,
and it takes an argument of T,
it declares a variable of type T,
and then the rest of it is simply exactly the same
as the non-recursive factorial function.
And here I'm demonstrating it using an integer,
a long, long unsigned integer, and a double.
And when I build and run,
you notice that I get these very interesting results.
In this challenge, you've used your understanding
of templates to create a template based solution
for the non-recursive factorial function.
I hope you can see how powerful and flexible
templates can be for generic programming in C++.