+ 1
Fill in the blanks to print 5.
template<_A> int sum(int n) {return A+n; } int main() {cout<<sum<__>(2);
1 Answer
+ 1
template<int A>
...
cout<<sum<3>(2);
The above uses the fact that templates can have 'non-type' arguments as well. In fact, for C++17 (and beyond) you can use 'auto' instead of 'int' and the compiler will infer the type.