I came across this a while ago, and I finally need to get an answer to this question.
The problem is this:
#include <iostream>
using namespace std;
template <class FIRST, class SECOND>
FIRST multiply(FIRST a, SECOND b){
return a * b;
}
int main(){
int x = 39;
double y = 38.38;
cout << multiply(x, y) << endl;
}
In this C ++ code, I have two template parameters, and the return type is the type of one parameter. My problem is that the return type must be (in this case) the same type as the variable a. I tried it with the THIRD template parameter, but it gave me a compilation error, can anyone explain this to me?
long - , , " " , ( , , - , ).