How would you create a function template with more than one type parameter?
|
If you don’t know what a function template is, then it would help if you read our quick refresher on function templates.
You may find yourself needing to use more than one type parameter in a function template. If that ever occurs, then declaring multiple type parameters is actually quite simple. All you need to do is add the extra type to the template prefix, so it looks like this:
// 2 type parameters: template<class T1, class T2> void someFunc(T1 var1, T2 var2 ) { // some code in here... }
No comments:
Post a Comment