+ 1

Fill in the blanks to print 5.

template<_A> int sum(int n) {return A+n; } int main() {cout<<sum<__>(2);

4th Mar 2017, 5:19 AM
Gaurav Kaushik
Gaurav Kaushik - avatar
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.
5th Mar 2017, 9:46 AM
Ettienne Gilbert
Ettienne Gilbert - avatar