0
Can't we use simply one template to check whether the number is greater?
6 Answers
+ 11
Harshit Nema , this is far too less information in your post. Please rework your question so that we clearly understand what problem you have. Also put the programming language in tag. Thanks!
+ 3
Harshit Nema
If we only use T then both argument must be of the same type, as I understand.
+ 1
Lothar now you can see it
+ 1
"Can't we use simply one template..."
Yes, but that function compares an int and a double. That's why two template class were used. You can use just one template class if you are sure the two function parameters' type were of the same data type.
+ 1
int and double are fundamentally different types. Two different template generics makes the function possible for two different types or two parameters of the same type. It's just as Ipang said, if you want the function to be defined for only one type, then use one template, else if you want it be defined for different types, you have to have two templates.
0
Yes that's my point.