#include <iostream>
using namespace std;
template <typename x> x functionA (x, x);
int main ()
{
functionA <double, double, double> (1, 1) << "\n";
}
template <typename x> x functionA (x arg1, x arg2)
{
return arg1 + arg2;
}
This code results in:
error: no matching function for call to ‘functionA(int, int)’
What can be the reasons?
The function template has one template parameter only, and you’re passing
3template arguments to it:Why
3template arguments?Just write:
Or you can simply let the compiler deduce the template argument, as: