I am new to templates and I am trying to test this out after reading up on how to do templates, but I'm getting a compilation error and my code looks the exact same as the example I took from. I create a function and I have a template, but when I compile it I get the following error:
15 20 C:\Users\Fire\Desktop\test.cpp [Error] call of overloaded 'max(int, int)' is ambiguous
15 20 C:\Users\Fire\Desktop\test.cpp [Note] candidates are:
7 3 C:\Users\Fire\Desktop\test.cpp [Note] T max(T, T) [with T = int]
The code is as follows:
#include <iostream>
using namespace std;
template<typename T>
T max(T a, T b){
return (a > b)? a: b;
}
int main(){
cout << max<int>(10, 40);
return 0;
}