Your function template has three type template parameters: T, B, and C. You've given the compiler enough information to figure out B (your first function argument's type is int, so B must be int) and C (your second argument's type is int, so C must be int), but not enough to figure out T. What should it return? int? what if a+b doesn't fit in an int? long? long long?
In C++98, provide the argument:
1 2 3 4
int main()
{
add<int>(10, 20);
}
In C++11, you can calculate the return type from the parameter types:
1 2 3 4 5 6
template<typename B, typename C>
auto add(B a,C b) -> decltype(a+b)
{
auto ab = a+b;
return ab;
}
in C++14, you can let the compiler do that
1 2 3 4 5 6
template<typename B, typename C>
auto add(B a,C b)
{
auto ab = a+b;
return ab;
}